0
votes

Im having problems connecting to an access database found in the following path: C:\tgs_webedit\pool\n_pool.mdb.

Im using odbc connection and my problem is in the following line: OdbcConnection DbConnection = new OdbcConnection("DNS = C:\tgs_webedit\pool\n_pool.mdb");

Im getting the following error : System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Any help would be greatly appreciated.

3

3 Answers

1
votes

Try changing it to this:

OdbcConnection DbConnection = new OdbcConnection("Driver={Microsoft Access Driver (*.mdb)};DBQ = C:\\tgs_webedit\\pool\\n_pool.mdb");

If you want to use a DSN, then don't provide the path to the mdb file (and put DSN in your conneciton string in stead of DNS). If you are going to use a path, use the DBQ and escape the slashes. Here is a good link that goes over all of this:

http://msdn.microsoft.com/en-us/library/system.data.odbc.odbcconnection.connectionstring.aspx

1
votes

The syntactical problem:

Either use a @-string OdbcConnection(@"DNS = C:\tgs_webedit\pool\n_pool.mdb"); or escape the backslashes OdbcConnection("DNS = C:\\tgs_webedit\\pool\\n_pool.mdb");

The functional problem:

An ODBC DSN connection should specify a DSN name defined in the ODBC datasources. The driver may 'do the right thing' - or not. To be on the save side, test getting your connection in the standard way*.

  • standard way

Use "control panel" - "Administrative Tasks" - "Data Sources (ODBC)" to add a User or System DSN. Pick the Access driver, specify the Data Source Name and select/browse for your n_pool.mdb. You can then test the connection and perhaps set some options. Use the Data Source Name in your connection string. (Using Abe Miessler's way (dsn-less connection) may be faster to try out, but the Data Sources GUI makes it easier to hunt down problems)

0
votes

You may have a problem with x64, Microsoft JET4.0 only works with x86 (or maybe I am totaly wrong and this has nothing to to with JET and the non-porting problem to x64)