我使用的部分代码如下:
datapath = App.Path + "\db1.mdb"
linkdata = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + datapath + ";Persist Security Info=False" + ";Jet OLEDB:Database Password=123"sub form_load()
Adodc1.ConnectionString = linkdata
Adodc1.RecordSource = "select * from login"
Adodc1.CommandType = adCmdUnknown
Adodc1.Refresh
End sub出现了[ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
datapath = App.Path + "\db1.mdb"
linkdata = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + datapath + ";Persist Security Info=False" + ";Jet OLEDB:Database Password=123"sub form_load()
Adodc1.ConnectionString = linkdata
Adodc1.RecordSource = "select * from login"
Adodc1.CommandType = adCmdUnknown
Adodc1.Refresh
End sub出现了[ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
改成
linkdata="provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False ;Jet OLEDB:Database Password=123 ;Data Source= "+app.path+"/db1.mdb"
再试试...
& "Data Source=" & DbName & ";Jet OLEDB:Database Password=123" CN.ConnectionString = ConString
CN.Open
datapath = App.Path & "\db1.mdb "
linkdata = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & datapath & ";Persist Security Info=False;Jet OLEDB:Database Password=123"
Adodc1.ConnectionString = linkdata
Adodc1.RecordSource = "select * from login "
Adodc1.CommandType = adCmdUnknown
Adodc1.Refresh
End sub
2、手动生成连接字符串测试jet.OLEDB是否正常
Set Mconnection = New Connection
MconnectionString = "Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;Initial Catalog=yinlun;User ID=sa;Data Source=."
With Mconnection
.ConnectionString = MconnectionString
.Open
End With