VB做登陆界面的代码出现问题

来源:百度知道 编辑:UC知道 时间:2024/05/25 11:39:33
Private Sub CmdCancel_Click()
Unload Me
End Sub
Private Sub CmdOK_Click()
Dim check As New ADODB.Recordset
Dim DBstr As String
Dim UserID As String
Dim UserPwd As String
If Len(Trim(Me.TextUser.Text)) <= 0 Then
MsgBox "请输入用户名!", , "登录信息"
Exit Sub
End If
If Len(Trim(Me.TextUser.Text)) > 8 Then
MsgBox "您输入用户名过长!", , "登录信息"
Exit Sub
End If

If Len(Trim(Me.TextPwd.Text)) <= 0 Then
MsgBox "请输入密码!", , "登录信息"
Exit Sub
End If
If Len(Trim(Me.TextPwd.Text)) > 8 Then
MsgBox "您输入密码过长!", , "登录信息"
Exit Sub
End If
DBstr = "select * from UserInfo where UserID='" & UserID & "'"
If check.EOF Then
MsgBox "没有该用户!", , "登录信息"
check.Close
Exit

DBstr = "select * from UserInfo where UserID='" & UserID & "'"
check.Open DBstr, conn, 3,2

你没打开对象,lzh741206给你的答案是正确的
先赋值:
DBstr = "select * from UserInfo where UserID='" & UserID & "'"
接着:
check.open dbstr,conn,3,2