帮我看看这个登录的代码错在哪里?
Function IsExistUser(ByVal tmp_UserName As String, ByVal tmp_UserPwd As String) As Boolean
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
sqlstr = "select UserName,UserPwd from M_User where UserName='" & tmp_UserName & "' and UserPwd='" & tmp_UserPwd & "'"
rst.Open sqlstr, conn, adOpenKeyset, adLockReadOnly
If rst.BOF = False Then
IsExistUser = True
Else
IsExistUser = False
End If
rst.Close
Set rst = Nothing
End Function
Private Sub cmdEnter_Click()
On Error GoTo errLoad
Dim i As Integer
i = 3
If Len(cmbName.Text) = 0 Then
MsgBox "請輸入用戶名", vbInformation, "提示"
Exit Sub
ElseIf Len(txtPwd.Text) = 0 Then
MsgBox "密碼不能為空", vbInformation, "提示"
Exit Sub
ElseIf Len(cmbServer.Text) = 0 Then
MsgBox "請選擇服務器", vbInformation, "提示"
Exit Sub
Else
If IsExistUser(cmbName, Trim(txtPwd)) = False Then
MsgBox "用戶名或密碼不正確,請重新輸入", vbExclamation, "警告"
i = i - 1
cmbName.Text = ""
txtPwd.Text = ""
cmbName.SetFocus
If i = 0 Then
MsgBox "您三次登錄不成功,退出系統", vbInformation, "提示"
Exit Sub
End If
End If
End If
frmLogin.Hide
Load mdiMain
mdiMain.Show
errLoad:
MsgBox "錯誤" & Err.Number & ":" & Err.Description, vbCritical
Err.Clear
End Sub