麻烦大神进来指导一下
程序代码:
Private Sub CmdLogin_Click() Static n As Integer If n >= 3 Then MsgBox "输入用户名或密码次数大于3次,不允许继续登陆" End End If Set conn = New ADODB.Connection Call SJK(conn) Dim sql As String Dim rs_login As New ADODB.Recordset If Trim(TextName.Text) = "" Then MsgBox "用户名不能为空,请重新输入!", vbOKOnly + vbExclamation, "错误" TextName.SetFocus Else sql = "select 员工号,密码,姓名,权限 from 管理组 where 员工号='" & Trim(TextName.Text) & " ' and 密码= '" & Trim(TextPsw.Text) & " 'and 姓名= '" & name & " ' and 权限= '" & Class & " '" rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic uname = name Pclass = Class If rs_login.EOF = True Then MsgBox "用户名或密码不存在,请重新输入!", vbOKOnly + vbExclamation, "错误" TextName = "" TextName.SetFocus Else '检测密码正确与否 If Trim(rs_login.Fields("密码")) = Trim(TextPsw) Then rs_login.Close Unload Me FormHome.Show Else n = n + 1 MsgBox "第" & n & "次用户名或密码错误,请重新输入!", vbOKOnly + vbExclamation, "错误" TextPsw.SetFocus End If End If End If End Sub
F5运行没问题,一直提示用户不存在,难道说是我数据库问题?