我在vb中应用adodb来更新数据库 例如 我想修该密码的操作
Option Explicit Dim textSQl As String Dim msgtext As String Dim cn As ADODB.Connection Dim mrc As ADODB.Recordset Private Sub Form_Load()
Set cn = New Connection Set mrc = New Recordset cn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=学生管理.mdb") cn.CommandTimeout = 10 mrc.Open "登录", cn, adOpenKeyset, adLockPessimistic End Sub
Private Sub Command1_Click() If Trim(Text2.Text) <> Trim(Text3.Text) Then MsgBox "输入密码有错误,请重新输入", 16, "警戒" Text1.Text = "" Text2.Text = "" Text3.Text = "" Text1.SetFocus Else textSQl = "select * from 登录 where 密码= '" & Text1.Text & "'" Set mrc = cn.Execute(textSQl) If mrc.EOF = True Then MsgBox "输入密码有错误,请重新输入", 16, "警戒" Text1.Text = "" Text2.Text = "" Text3.Text = "" Text1.SetFocus Else mrc.Fields(1) = Text2.Text mrc.Update mrc.Close MsgBox "密码修改成功,请继续使用!", 64 + vbOKOnly, "修改成功" Me.Hide cn.Close Set cn = Nothing End If End If End Sub
Private Sub Command2_Click() Unload Me End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Command1_Click End If End Sub
结果出现“当前记录集不支持更新。这可能是提供程序的限制,也可能是选定锁定类型的限制”提示