Collection of ADO Recordsets and/or ADO Connections
Hello,
We use NUMEGA FAILSAFE for Error Trapping and when one of applications
throws an error, Failsafe try's to handle things, sometimes better than
others. I am trying to find a collection of 'active' ADO RS's and CNN's
that I can loop through and close if I need to.
In RDO, when my VB program 'ungracefully exited, I could call a procedure
that did this:
***************************
Dim DBInstance As Database
Dim RSInstance As Recordset
On Error Resume Next
For Each DBInstance In Workspaces(0).Databases
For Each RSInstance In DBInstance.Recordsets
'Close all recordsets
RSInstance.Close
Next
'Close database
DBInstance.Close
Next
***************************
Yes, I could call the unload event of my main form (which contains all the
normal exiting stuff), but in some apps, the main form is not loaded and VB
would have to LOAD it to UNLOAD IT. Also, guess I could make my own
collection of RS's and CNN's, but wanted to use 'built in' ones if possible.
Currently, I am doing this in my Form UNLOAD...
*********************************
If grsOne.State = 1 Then
grsOne.Close
Set grsOne = Nothing
End If
If grsTwo.State = 1 Then
grsTwo.Close
Set grsTwo = Nothing
End If
If grsThree.State = 1 Then
grsThree.Close
Set grsThree = Nothing
End If
If gcnnMainDB.State = 1 Then
gcnnMainDB.Close
Set gcnnMainDB = Nothing
End If
If gcnnSecondDB.State = 1 Then
gcnnSecondDB.Close
Set gcnnSecondDB = Nothing
End If
*********************************
I am looking for something like this...
For Each ADOCONNECTION in ADOCONNECTIONSCOLLECTION
If there are any RS's using this connection then
Close each of them and set to nothing
Else
Ok Then
End If
Next
*********************************
Thanks in advance for your help.
Cam