奇怪的登录问题
今天刚做好一款自用软件,测试了一下,发现在登录时用在数据库中编号为1的用户名才能登录进入系统,如果用编号为2的用户名登录,在按下登录按钮后没有任何反应,不知是何原因,代码如下,望各位学长指点Private Sub Command1_Click()
Dim ConStr As String
If Combo1.Text = "" Then
MsgBox "请输入用户名!", vbOKOnly + vbExclamation, "登录错误提示"
Combo1.SetFocus
Exit Sub
End If
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & App.Path & "\backstage\backstage.mdb"
cn.Open ConStr
cn.CursorLocation = adUseServer
rs.Open "Select * From 用户", cn, adOpenKeyset, adLockPessimistic
If rs.RecordCount > 0 Then
If Combo1.Text <> "" Then
Set rs1 = New ADODB.Recordset
rs1.Open "Select * From 用户 Where 用户名= '" & Combo1.Text & "'", cn, adOpenKeyset, adLockPessimistic
If rs.RecordCount > 0 Then
If Text1.Text <> "" Then
If rs.Fields("用户名") = Combo1.Text And rs.Fields("密码") = Text1.Text And rs.Fields("权限") = Combo2.Text Then
主窗口.Show
rs1.Close
Unload Me
Else
If rs1.Fields("密码") <> Text1.Text Then
MsgBox "密码错误,请与管理员联系!", vbCritical + vbOKOnly, "密码错误提示"
Text1.SetFocus
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Exit Sub
Else
If rs1.Fields("权限") <> Combo2.Text Then
MsgBox "权限错误,请与管理员联系!", vbOKOnly + vbCritical, "权限错误提示"
Combo2.SetFocus
Exit Sub
End If
End If
End If
Else
MsgBox "请输入密码!", vbOKOnly, "登录提示"
Text1.SetFocus
Exit Sub
End If
Else
MsgBox "没有该用户,请与管理员联系!", vbOKCancel + vbExclamation, "登录提示"
Combo1.SetFocus
Exit Sub
End If
End If
Else
End If
rs.Close
End Sub
[此贴子已经被作者于2007-8-13 18:52:38编辑过]