VB 打开带密码的数据库进行操作??
DimCnnAsADODB.ConnectionDimRsAsADODB.RecordsetSetCnn=NewADODB.ConnectionSetRs=NewADOD...
Dim Cnn As ADODB.Connection
Dim Rs As ADODB.Recordset
Set Cnn = New ADODB.Connection
Set Rs = New ADODB.Recordset
Cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\data\ysmx.mdb" + ";password=us5201314sw;Persist Security Info=False"
Rs.CursorLocation = adUseClient
Rs.Open "select * from 表2", Cnn, 1, 3
这里的密码应该如何写上去,才能打开操作 展开
Dim Rs As ADODB.Recordset
Set Cnn = New ADODB.Connection
Set Rs = New ADODB.Recordset
Cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\data\ysmx.mdb" + ";password=us5201314sw;Persist Security Info=False"
Rs.CursorLocation = adUseClient
Rs.Open "select * from 表2", Cnn, 1, 3
这里的密码应该如何写上去,才能打开操作 展开
2个回答
展开全部
加单引号
Cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\data\ysmx.mdb" + ";password='us5201314sw';Persist Security Info=False"
Cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\data\ysmx.mdb" + ";password='us5201314sw';Persist Security Info=False"
追问
Private Sub Command4_Click()
Dim dbs As Database
Set dbs = DBEngine.OpenDatabase("" & App.Path & "\data\ysmx.mdb", , "me Access;pwd=us5201314sw")
dbs.Execute "ALTER TABLE jbxx " _
& "ADD COLUMN Salary CHAR(20); "
dbs.Close
我使用的是ADO 为啥总提示密码无效
追答
你这叫DAO,过时了,我上面说的才是ADO。
DAO这样:
Set dbs = DBEngine.OpenDatabase (App.Path & "\data\ysmx.mdb", , "us5201314sw")
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询