DB connection~ working on local not on server

0

I have a query that is working fine on my local but when placed on the server it comes back with this error,

Server Error in 'Page' Application.

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[OdbcException (0x80131937): ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified] System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode) +1159314 System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) +95 System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions) +53 System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +55 System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +29 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +4866464 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117 System.Data.Odbc.OdbcConnection.Open() +40 System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +31 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +112 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +287 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +92 System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1297 System.Web.UI.WebControls.BaseDataList.GetData() +38 System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean useDataSource) +153 System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +54 System.Web.UI.WebControls.BaseDataList.DataBind() +55 System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +60 System.Web.UI.WebControls.BaseDataList.OnPreRender(EventArgs e) +15 System.Web.UI.Control.PreRenderRecursiveInternal() +80 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

any ideas? cheers!

vb.net
visual-studio-2008
asked on Stack Overflow May 9, 2011 by Sam

1 Answer

0

You are using ODBC to connect to the server. You have to make sure that if you use a DSN (named ODBC connection that is stored on the server) that you create it on the server this code is running on. If you use a DSN-less connection (you do the setup in your code), you need to make sure the ODBC driver you are using is installed on the server.

A DSN-less connection string might look like this:

Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes;

Not all of them specify a driver but in this case it does. You would need to make sure that the "SQL Native Client" driver was installed on your server. A DNS connection would have a DSN entry in this string instead, like so:

DSN=MyDBConnection;

Look through your code and you will find out which you have. Once you find that out, find out what you need to put on the server. Most likely you need to add a DSN to the server. This is done by going to the Control Panel and searching for ODBC. Once you are there, you can create a new ODBC entry that matches the one on your development machine. Here is a link on creating an ODBC (DSN) entry:

http://support.microsoft.com/kb/305599

Make sure you create a DNS under the System, not the User tab. That way, it is available for any login the application might run under.

answered on Stack Overflow May 9, 2011 by IAmTimCorey • edited May 9, 2011 by IAmTimCorey

User contributions licensed under CC BY-SA 3.0