帮我看看这个登录的代码错在哪里?

leon2008go 2006-09-02 10:32:21
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
...全文
188 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
leon2008go 2006-09-02
  • 打赏
  • 举报
回复
谢谢
zq972 2006-09-02
  • 打赏
  • 举报
回复
Private Sub cmdEnter_Click()
On Error GoTo errLoad

Static 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

exit sub'----这句不能少
errLoad:
MsgBox "錯誤" & Err.Number & ":" & Err.Description, vbCritical
Err.Clear
End Sub

7,764

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧