Results 1 to 3 of 3

Thread: How to close ADO Recordsets en mass?

  1. #1

    Thread Starter
    Addicted Member P.S.W.'s Avatar
    Join Date
    Aug 2000
    Posts
    146

    How to close ADO Recordsets en mass?

    Hey guys,

    Does anyone know of a way to close all the open ADO recordsets without having to refer to them individually by name?

    For example, I have about 20 recordset objects which I currently close like this:

    rs1.close
    rs2.close
    rs3.close

    ...etc.

    I'd like to be able to just run a loop which would automatically close all open recordsets, just like you can close all open forms with a forms collection, for example. Is it possible?

  2. #2
    Lively Member
    Join Date
    Oct 2002
    Location
    Los Angeles, CA
    Posts
    73
    You can write an object/collection wrapper which will hold references of all opened recordsets, so that when you open recordset you use Add method of this object. This object should have method CloseAll, which internally will loop through all recordsets and close them.

  3. #3
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    VB Code:
    1. Dim RS(1 To 4) AS New ADODB.Recordset
    2.  
    3. set RS(1) = oConn.Execute(My-SQL-Stuff)
    4. set RS(2) =     "
    5.   "     "(3) =     "
    6.   "     "(4) =     "          
    7.  
    8. Dim i as integer
    9. For i=1 To 4
    10.       RS(i).Close
    11. Next i

    That should also work?
    Wayne

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width