我在访问数据库上设置了密码并试图通过此代码访问它,但是在使用(cnn.open)时它不起作用并且不访问数据库。我该怎么做? (我把1234作为密码示例)
cnn.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Password="""";Data Source=C:\SecGrd" & _
"\SecGrd.mdb;Mode=Share Deny None;Extended Properties="""";Jet OLEDB:System databas" & _
"e="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine " & _
"Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet" & _
" OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:C" & _
"reate System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Cop" & _
"y Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLE" & _
"DB:SFP=False")
CCCommand.SelectCommand.Connection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Password="""";Data Source=C:\SecGrd" & _
"\SecGrd.mdb;Mode=Share Deny None;Extended Properties="""";Jet OLEDB:System databas" & _
"e="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine " & _
"Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet" & _
" OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:C" & _
"reate System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Cop" & _
"y Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLE" & _
"DB:SFP=False")
CCCommand.SelectCommand.CommandText = "select * from CC_Main"
CCCommand.TableMappings.Add("Table", StudentsGradesDataset.CCMTable)
答案 0 :(得分:0)
20年前我遇到了同样的问题! 所以我找到了解决方案并使用了这个连接字符串自20年前以来!
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\data\base\main.mdb;Persist Security Info=True;Jet OLEDB:Database Password=1234"
providerName="System.Data.OleDb"
注意:
1-将数据库路径放在此处:| DataDirectory | \ data \ base \ main.mdb
2 - 20年前它的工作状态很好,所以尽情享受!!!