小第我做了一个密码登录,想把登录不成功的次数放入数据库中,下次该用户登录时就知有非法用户在猜密码。但怎么都update不进去,望各位指教!
       Dim rsUser As New ADODB.Recordset
       If conn.State = 1 Then
        rsUser.Open " select * from tpass where Name='" & Combo1.Text & "'", conn, adOpenStatic, adLockBatchOptimistic
        If rsUser.State = 1 Then
            If rsUser.RecordCount > 0 Then
                If rsUser.Fields("PassWord").Value = Text1.Text Then
                    MsgBox "密码正确,欢迎使用", vbOKOnly + vbInformation, "登录成功"
                    Unload Me
                    fmain.Show
                    fmain.Enabled = True
                Else
                    MsgBox "密码错误,请重输", vbOKOnly + vbInformation, "登录失败"
                    passcheck = passcheck + 1
                   '此处就是update的地方
                    rsUser!passid = passcheck
                    rsUser.Update
                End If
            End If
        End If
      End If

解决方案 »

  1.   

    passcheck = passcheck + 1有问题?
      

  2.   

    没有rsUser.edit,直接rsUser.Update能行吗?
      

  3.   

    你的问题是你没有判断这个用户是否已经存在
    加个判断
    if存在 then
      该用户passcheck + 1
    else
      新建该用户 1
    endif
      

  4.   

    你没有判断这个用户是否已经存在
    加个判断
    if存在 then
      该用户passcheck + 1
    else
      新建该用户 1
    endif
      

  5.   

    rsUser.Open " select * from tpass where Name='" & Combo1.Text & "'", conn, adOpenStatic, adLockBatchOptimistic改成rsUser.Open " select * from tpass where Name='" & Combo1.Text & "'", conn
      

  6.   

    rsUser.Open " select * from tpass where Name='" & Combo1.Text & "'", conn, adOpenStatic, adLockBatchOptimistic改为rsUser.Open " select * from tpass where Name='" & Combo1.Text & "'", conn
      

  7.   

    你只是更新一条记录,不必使用adLockBatchOptimistic,要用adLockOptimistic
      

  8.   

    即rsUser.Open " select * from tpass where Name='" & Combo1.Text & "'", conn, adOpenStatic, adLockBatchOptimistic 改成
    rsUser.Open " select * from tpass where Name='" & Combo1.Text & "'", conn, adOpenStatic, adLockOptimistic
      

  9.   

    首先提取数据库中的 
    select * from user where username='"& combo1.text &"'
    打开数据库....
    哎  也就是 qingming81所写的.....