Religion & Spirituality3 mins ago
Hi Everyone
1 Answers
Hi. May anyone please help me get rid of this error: " Operation is not allowed when the object is closed ".
I'm using vd6 Adodc1 to connect to database. I'm trying to change password, and it actually updates it but it comes with above error after an update is done. How do I eradicate this problem.
Below is my code:
Private Sub cmdUpdate_Click()
On Error GoTo errHandler
Dim mSQL As String
Screen.MousePointer = 11
With Adodc1
.CommandType = adCmdText
mSQL = " update princ_access SET [password] = '" & txtNewpass.Text & "' WHERE password like '" & txtOldpass.Text & "'"
.RecordSource = mSQL
Adodc1.Refresh
End With
Set txtNewpass.DataSource = Adodc1
errHandler:
Screen.MousePointer = 0
MsgBox Err.Number & Err.Description
End Sub
I'm using vd6 Adodc1 to connect to database. I'm trying to change password, and it actually updates it but it comes with above error after an update is done. How do I eradicate this problem.
Below is my code:
Private Sub cmdUpdate_Click()
On Error GoTo errHandler
Dim mSQL As String
Screen.MousePointer = 11
With Adodc1
.CommandType = adCmdText
mSQL = " update princ_access SET [password] = '" & txtNewpass.Text & "' WHERE password like '" & txtOldpass.Text & "'"
.RecordSource = mSQL
Adodc1.Refresh
End With
Set txtNewpass.DataSource = Adodc1
errHandler:
Screen.MousePointer = 0
MsgBox Err.Number & Err.Description
End Sub
Answers
Best Answer
No best answer has yet been selected by Makhosi. Once a best answer has been selected, it will be shown here.
For more on marking an answer as the "Best Answer", please visit our FAQ.From the horrible syntax, I assume that you meant to type VB6 rather than vd6.
Reading your code (and I'm not a BASIC programmer), it looks awfully like your error handler is going to get called even when there's no error (i.e immediately after the line: "Set txtNewpass.DataSource = Adodc1 ".)
Have a look at the second example on this page: http://www.vb6.us/tut...ror-handling#Trapping
Reading your code (and I'm not a BASIC programmer), it looks awfully like your error handler is going to get called even when there's no error (i.e immediately after the line: "Set txtNewpass.DataSource = Adodc1 ".)
Have a look at the second example on this page: http://www.vb6.us/tut...ror-handling#Trapping