![]() |
#2
mpy20032013-04-17 08:36
回复 楼主 mpy2003
|

Dim SQL As String
Set Con = New ADODB.Connection
Con.Open "provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & SetUp.Text(0) & "\Data.accdb"
SQL = "update 数据库信息 Set 状态='" & MDI.StatusBar.Panels(2) & "' Where ID=1"
Con.Execute SQL
Con.Close
Set Con = Nothing
上面的代码一直显示语法错误,下面的能正确Set Con = New ADODB.Connection
Con.Open "provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & SetUp.Text(0) & "\Data.accdb"
SQL = "update 数据库信息 Set 状态='" & MDI.StatusBar.Panels(2) & "' Where ID=1"
Con.Execute SQL
Con.Close
Set Con = Nothing

Set Con = New ADODB.Connection
Con.Open "provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & SetUp.Text(0) & "\Data.accdb"
Set Rs0 = New ADODB.Recordset
Rs0.Open "select * from 数据库信息", Con, 3, 3
Do While Not Rs0.EOF
If Rs0.Fields("ID") = 1 Then
Rs0.Fields("状态") = MDI.StatusBar.Panels(2)
Exit Do
End If
Rs0.MoveNext
Loop
Rs0.Close
Con.Close
Set Rs0 = Nothing
Set Con = Nothing
谁能告诉我这是为什么?要怎么写?Con.Open "provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & SetUp.Text(0) & "\Data.accdb"
Set Rs0 = New ADODB.Recordset
Rs0.Open "select * from 数据库信息", Con, 3, 3
Do While Not Rs0.EOF
If Rs0.Fields("ID") = 1 Then
Rs0.Fields("状态") = MDI.StatusBar.Panels(2)
Exit Do
End If
Rs0.MoveNext
Loop
Rs0.Close
Con.Close
Set Rs0 = Nothing
Set Con = Nothing
[ 本帖最后由 mpy2003 于 2013-4-16 09:19 编辑 ]