Search code examples
c#ms-accessado.netodbcoledb

"Data source name not found and no default driver specified" for creating access connection


This is my connection to an access database in .NET:

OdbcConnection conn = new OdbcConnection("Driver={Microsoft Access Driver (*.mdb)};Dbq=" + path + "\\Access.mdb;Uid=;Pwd=;");

And I got this problem:

base {System.Data.Common.DbException} = {"ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"}

I have tried couple of database connection strings from here: http://www.connectionstrings.com/access but none of them working.

Any suggestions for this?

Thanks in advance.


Solution

  • There is an easy way to get the connection string, try it as follow:

    • Create a text file and change it's extension to .udl.
    • Open the new file by double click it and choose to open it with any text editor, notepad for example.
    • In the opened window, choose your provider and your database and click OK.
    • Open this file with notepad as a text and you will find the connectoin string inside it.

    See This for more details.