如何连接Ms access 2010.Accdb)数据库与odbc驱动程序
本文关键字:Accdb 数据库 驱动程序 odbc 2010 Ms 何连接 连接 access | 更新日期: 2023-09-27 17:50:31
谁能告诉我怎么连接Ms access 2010 ?c#和。net 4.0的odbc驱动程序
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 ! ");
}
抛出这个异常
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and not default Driver specified exception
您的连接字符串中有一个错别字:
string connectionString = ("Driver={Microsoft Access Driver(*.mdb, *.accdb)};DBQ=C:''Users''Administrator''Desktop''New folder''MatchDetails.accdb;");
(注意Driver名中的逗号)
我在驱动程序名中看到两个拼写错误:
- 括号 前没有空格
- 括号 内没有逗号
正确连接字符串:
string connectionString = ("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:''Users''Administrator''Desktop''New folder''MatchDetails.accdb;");