怎么更新Access数据库?
本帖最后由 mpy2003 于 2013-04-16 09:25:29 编辑 从网上找了好多例子,于是我写成了update语句,出现语法错误:
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"
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