“添加用户”“删除用户”“修改密码”均出现同样的错误。
Private Sub Command1_Click()Dim sql As String
Dim rs_adduser As New ADODB.Recordset
Dim cn As New ADODB.Connection
cn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\database.mdb"
If Trim(Text1.Text) = "" Then
MsgBox "用户名不能为空"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
Exit Sub
Else
sql = "select * from user where 1=1"
rs_adduser.Open sql, cn, adOpenKeyset, adLockPessimistic
While (rs_adduser.EOF = False)
If Trim(rs_adduser.Fields(0)) = Trim(Text1.Text) Then
MsgBox "已有这个用户,请重新输入"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
Exit Sub
Else
rs_adduser.MoveNext
End If
Wend
If Trim(Text2.Text) <> Trim(Text3.Text) Then
MsgBox "两次密码输入不一致,请重新输入", vbOKOnly + vbExclamation, "提示"
Text2.Text = ""
Text3.Text = ""
Text2.SetFocus
Exit Sub
Else
rs_adduser.AddNew
rs_adduser.Fields(0) = Text1.Text
rs_adduser.Fields(1) = Text2.Text
rs_adduser.Update
MsgBox "添加新用户成功", vbOKOnly + vbExclamation, "提示"
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
出错提示“from 子句语法错误”
提示错误在“rs_adduser.Open sql, cn, adOpenKeyset, adLockPessimistic”