纸托模具招工:VB 关于登录框和数据库,头大了

来源:百度文库 编辑:高校问答 时间:2024/05/04 17:08:32
不知道怎么改了,老是不对,帮帮我

Private Sub cmdOK_Click()
If Trim(txtUserName.Text) = "" Then
MsgBox "没有输入用户名称,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
GetConnected
Set rs = New ADODB.Recordset
str = "select * from login where name ='" & txtUserName.Text & "'"
rs.Open str, cn, adOpenDynamic, adLockOptimistic
If rs.EOF = True And rs.BOF = True Then
txtUserName.Text = ""
txtPassword.Text = ""
MsgBox "没有这个用户,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
If Trim(txtUserName.Text) = Trim(rs!Password) Then
txtUserName.Text = rs!Name
rs.Close
txtUserName = Trim(txtUserName.Text)
MDIForm1.Show
Unload Me
Else
MsgBox "无效的密码,请重试!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End If
End If
End Sub

If rs.EOF = True And rs.BOF = True Then
条件不可能成立!!!!!
If rs.EOF OR rs.BOF Then