'how to solve run-time error 3704 in vb6.0?
just like yugal, I am getting error 3704-Operation not allowed when the object is closed. Please help me fix this problem with my system.. this is my code:
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
Thanks, alex.
Solution 1:[1]
Your Error is occuring because you are attempting to open a "SELECT" recordset with the execute command, this is used for action queries such as "INSERT, UPDATE" etc. In this case you need to use the .open command with your ADO recordset.
Solution 2:[2]
error >> Set rsenrol = cnenrol.Execute("Select * from tblUsers where username = '" & txtUser & "'and password='" & txtpass & "'")[this is where the error occur] <<
new code dim sqls If rsenrol.State = adStateOpen Then rsenrol.Close sqls="Select * from tblUsers where username='" & txtUser & "'and password='" & txtpass & "'" rsenrol.open sqls, cnenrol, 1, 2
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Matt Donnan |
| Solution 2 | adenana mohammed |
