报这个错误是因为Acess的版本不同。

ODBC连接时报错不可识别的数据库格式

 

 

2003版本的Acess的数据连接字符串:

 string dataBasePath = @"C:/Users/user/Documents/Test.mdb";

 string connectionString = "provider=microsoft.jet.oledb.4.0;Data Source=" + dataBasePath + ";";

 

2007版本的Acess的数据连接字符串:

string dataBasePath = @"C:/Users/user/Documents/Test.accdb";

string connectionString = "provider=microsoft.ace.oledb.12.0;Data Source=" + dataBasePath + ";";

 

所以需要看一下ODBC连接驱动的后缀名是否和数据库后缀名一致。

相关文章: