如何解决vb6.0中的运行时错误3704?

时间:2012-01-14 04:02:44

标签: vb6

就像yugal一样,我收到错误3704-当对象关闭时不允许操作。 请帮我解决我的系统问题.. 这是我的代码:

Private Sub cmdLog_Click()
txtUser.SetFocus
frmChange.txtusern = txtUser
If txtUser <> "" And txtpass <> "" Then
    **Set rsenrol = cnenrol.Execute("Select * from tblUsers where username = '" & txtUser & "'and password='" & txtpass & "'")**[this is where the error occur]
    If csenrol.EOF = False Then
    MsgBox "Welcome " & txtUser & "!!", vbInformation, "Welcome User"
            txtUser = ""
            txtpass = ""
            Unload Me
            MDIfrm.Show
         Else
         MDIfrm.Visible = False
            MsgBox "Incorrect Username and/or Password. Please verify and Click Retry.", vbRetryCancel, "Log in Error"
            txtpass = ""
            txtUser.SetFocus
            Exit Sub
        End If
Else
    MsgBox "Sorry, I cannot identify you.", vbExclamation, "Intruder Alert"
    MDIfrm.Visible = False
    Exit Sub
End If
End Sub

谢谢, 亚历克斯。

1 个答案:

答案 0 :(得分:4)

您的错误正在发生,因为您正在尝试打开&#34; SELECT&#34;带有execute命令的记录集,用于行动查询,例如&#34; INSERT,UPDATE&#34;在这种情况下,您需要将.open命令与ADO记录集一起使用。