当前位置:编程学习 > VB >>

对象变量或with块变量未设置,不会改错,求帮助

Private Sub cmdOK_Click()
    Dim txtSQL As String
    Dim mrc As ADODB.Recordset
    Dim MsgText As String
    'ToDo: create test for correct password
    'check for correct password
    
    UserName = ""
    If Trim(txtUserName.Text = "") Then
        MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
        txtUserName.SetFocus
    Else
        txtSQL = "select * from user_Info where user_ID = '" & txtUserName.Text & "'"
        Set mrc = ExecuteSQL(txtSQL, MsgText)
        If mrc.EOF = True Then
            MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
            txtUserName.SetFocus
        Else
            If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
                OK = True
                mrc.Close
                Me.Hide
                UserName = Trim(txtUserName.Text)
            Else
                MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
                txtPassword.SetFocus
                txtPassword.Text = ""
            End If
        End If
    End If
    
    miCount = miCount + 1
    If miCount = 3 Then
        Me.Hide
    End If
    Exit Sub
End Sub



貌似是     If mrc.EOF = True Then
这里出了毛病,高手帮帮忙把

本人比较急,谢谢大哥大姐了 set mrc=new ADODB.Recordset 缺少引用
VB菜单栏 工程-->引用-->Microsoft AcitveX Data Objects 2.x。。。
引用楼主 jiejiejiezaizai 的回复:
貌似是 If mrc.EOF = True Then
这里出了毛病,高手帮帮忙把

mrc记录集没有正常打开,查检它的来源是否正常。
Dim mrc As ADODB.Recordset
你少写了一个new
Dim mrc As new ADODB.Recordset
补充:VB ,  控件
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,