VS2010中用C#语句连接Access2010数据库问题

2024-11-19 01:51:37
推荐回答(2个)
回答(1):

连接Access用“Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MTLM.mdb;Persist Security Info=False”字符串试下,一般连接excel用Provider=Microsoft.ACE.OLEDB.12.0;而连接Access用Provider=Microsoft.Jet.OLEDB.4.0;

回答(2):

string _strConn = @"provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + "Tabel1.accdb"; //access 2010
string _strConn = @"provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + "Tabel1.accdb"; //access 2003