Reputation: 45
Can any one tell how to connect Ms access 2010 (.accdb ) database with odbc driver in c# and .NET 4.0
I tried
string connetionString = ("Driver={Microsoft Access Driver(*.mdb*.accdb)};DBQ=C:\\Users\\Administrator\\Desktop\\New folder\\MatchDetails.accdb;");
OdbcConnection myConnection = new OdbcConnection(connetionString);
try
{
myConnection.Open();
MessageBox.Show("Connection Open ! ");
myConnection.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
throwing this Exception
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified exception
Upvotes: 2
Views: 22260
Reputation: 11
I see a two typos in driver name:
Correct connection string:
string connectionString = ("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\\Users\\Administrator\\Desktop\\New folder\\MatchDetails.accdb;");
Upvotes: 0
Reputation: 152501
You have a typo in your connection string:
string connectionString = ("Driver={Microsoft Access Driver(*.mdb, *.accdb)};DBQ=C:\\Users\\Administrator\\Desktop\\New folder\\MatchDetails.accdb;");
(note the comma in the Driver name)
Upvotes: 4