当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - How to connect Ms access 2010 (.accdb ) database with odbc driver

问题描述:

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

网友答案:

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)

分享给朋友:
您可能感兴趣的文章:
随机阅读: