Collection of ADO Recordsets and/or ADO Connections 
Author Message
 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



Sat, 02 Jul 2005 04:17:24 GMT  
 Collection of ADO Recordsets and/or ADO Connections

COM-based ADO "classic" and ADO.NET do not expose collections of Recordset
or Connection objects. They were only included in RDO to maintain backward
compatibility with DAO. However, there would be nothing to stop you from
creating and managing these collections yourself.

hth

--
____________________________________
Bill Vaughn
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________


Quote:
> 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



Sat, 02 Jul 2005 04:38:02 GMT  
 Collection of ADO Recordsets and/or ADO Connections
Cam,

Unfortunately there is no collection of recordsets or connections. If you
need it, then you need to create that collection as a class and each time,
when you create ne w connection or recordset, add it to collection.

--
Val Mazur
Microsoft MVP


Quote:
> 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



Sat, 02 Jul 2005 04:51:54 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Open ADO recordset on another ADO recordset - possible?

2. Trouble with ADO Connection.Open() Error 3625 Item not found in collection

3. ADO ADO ADO ADO ADO VB examples / samples book wanted

4. recordset fields collection - ado

5. Collection to ADO recordset?

6. recordset fields collection - ado

7. collections vs ado recordsets?

8. Collection Acting Like ADO Recordset

9. recordset fields collection - ado

10. passing a collection to a mts object with a ADO recordset

11. How many ADO recordsets can share a connection ?

12. Detecting how many recordsets are using an ADO connection

 

 
Powered by phpBB® Forum Software