VB+SQL 登录器,帮我看一下为什么老是密码错误。
F = 1
userkey = Trim(user.Text)
password = Trim(password.Text)
Adodc1.RecordSource = "select * from 用户 where [user] ='" & userkey & "'"
Adodc1.Refresh
If Adodc1.Recordset.BOF = True Then
MsgBox "找不到用户名"
F = 0
user.SetFocus
user.Text = ""
password.Text = ""
Exit Sub
End If
If F = 1 And password <> Adodc1.Recordset.Fields(1) Then
MsgBox "密码错误"
user.SetFocus
user.Text = ""
password.Text = ""
Else
Unload Me
main.Show
End If
End Sub
可以查找用户,也可以判断,但是输入密码后,老是提示密码错误。 我怀疑是 If F = 1 And password <> Adodc1.Recordset.Fields(1) Then 这段 有问题,麻烦大家帮我看看。
[最优解释]
'直接在SQL语句中判断吧:
Adodc1.RecordSource = "select * from 用户 where [user] ='" & userkey & "' and 密码字段='"& trim(txtpassword.text) &"'"