关于用VB做的登录界面的问题,VB高手请进
这是我在做学生管理系统时,代码出现了问题,请高手帮我看看,帮我改改,谢谢
Private Sub cmdOK_Click()
Dim sql As String
sql = "select userpassword from use where username='" & txtUserName & "'"
If txtUserName.Text = "" Then
MsgBox "请填写用户名!", vbOKOnly + vbInformation, "注意"
txtUserName.SetFocus
Exit Sub
ElseIf txtPassword.Text = "" Then
MsgBox "请填写密码!", vbOKOnly + vbInformation, "注意"
txtPassword.SetFocus
Exit Sub
End If
Adodc1.RecordSource = sql
Adodc1.Refresh
If Not Adodc1.Recordset.EOF Then
If Adodc1.Recordset!UserName <> txtUserName Then
MsgBox "用户名错误!"
txtUserName.SetFocus
txtUserName = ""
End If
Else
If Adodc1.Recordset!userpassword <> txtPassword Then
MsgBox "密码错误!"
txtPassword.SetFocus
txtPassword = ""
Else
MDIForm1.Show
Unload Me
End If
End If
End Sub
或者帮我写一个也行,好了的再给你加分,万般感谢!
参考答案:Private Sub cmdOK_Click()
Dim sql As String
sql = "select userpassword from use where username='" & txtUserName & "'"
If txtUserName.Text = "" Then
MsgBox , vbOKOnly + vbInformation,
txtUserName.SetFocus
Exit Sub
ElseIf txtPassword.Text = "" Then
MsgBox , vbOKOnly + vbInformation,
txtPassword.SetFocus
Exit Sub
End If
Adodc1.RecordSource = sql
Adodc1.Refresh
If Not Adodc1.Recordset.EOF Then
If Adodc1.Recordset!UserName <> txtUserName Then
MsgBox
txtUserName.SetFocus
txtUserName = ""
End If
Else
If Adodc1.Recordset!userpassword <> txtPassword Then
MsgBox
txtPassword.SetFocus
txtPassword = ""
Else
MDIForm1.Show
Unload Me
End If
End If
End Sub