I keep getting an error in my app: -
Operation is not allowed in this context
It seems to happen when I try to open a recordset that has caused an error in the past. When the error happens, my error handler jumps in: -
as you can see, the last 2 lines close the recordsets that have been used. closing them here does not cause any errors, butmy data class tries to close the set beofore opening it using this code: -Code:AddNewRecErr: MsgBox err.Number & ": " & err.Description For Each rec_err In NewRecSource.Cnn.Errors If TicketSaved = True Then message = rec_err.Number & ": " & err.Description & Chr$(13) & Chr$(13) & "Ticket Saved Okay" Else message = rec_err.Number & ": " & err.Description & Chr$(13) & Chr$(13) & "Ticket Not Saved" End If MsgBox message, vbExclamation, App.Title Next rec_err For Each rec_err In ImportDs.Cnn.Errors If TicketSaved = True Then message = rec_err.Number & ": " & err.Description & Chr$(13) & Chr$(13) & "Ticket Saved Okay" Else message = rec_err.Number & ": " & err.Description & Chr$(13) & Chr$(13) & "Ticket Not Saved" End If MsgBox message, vbExclamation, App.Title Next rec_err NewRecSource.Rs.Close ImportDs.Rs.Close
If i leave the lines to close the set out of my error handler, it throws the 'operation is not allowed...' error again when the class tries to close it, so i leave those 2 lines in. this doesnt really solve the problem, because when I try to open the set, i get the message again.Code:Public Sub SetRs(ByVal sql As String) If ErrorOccurred = True Then Exit Sub End If If Rs.State = 1 Then Rs.Close End If Rs.Open sql, Cnn, adOpenKeyset, adLockOptimistic End Sub
the only thing to do is to quit the app (causing more of the same errors as the connctions are closed) and restart it. Is there a better way????????
The I'm using a SQL 7 database accessed through an ADO data class. I have MDAC 2.5 installed on all machines, in case this is of any help.




Reply With Quote