Re: closing recordsets or not...

Re: closing recordsets or not...

am 14.12.2004 17:37:49 von Mark Schupp

A recordset should automatically close when it is re-opened or when it is
destroyed. Objects in ASP are destroyed when they are no longer referenced
by any variables. The exact point at which this "garbage collection" occurs
varies with the IIS version. Earlier versions destroy objects after the page
completes later versions (not sure the exact version that changed) can
destroy objects earlier if they are no longer referenced.

Because of the possiblity of circular references and potential bugs in the
garbage collector many developers use the following rules:

If you open it, close it
If you create it, destroy it

In the situation you described I would at least explicitly close the
recordset before each re-use and set it to Nothing after all the queries
were completed (a recordset is still an object even if it is no longer
open). I have on rare occasions found it necessary to close and set a
recordset to nothing prior to re-opening (involved transactions and Oracle
IIRC).

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com

"meg" wrote in message
news:uOXDf4V4EHA.1400@TK2MSFTNGP11.phx.gbl...
> Hello, I'm changing a website built by another. I notice that the writer
> doesn't ever close his recordsets,
> or set to nothing. But he does continually re-use the same variable (rs)
> throughout his code for different
> recordsets - always overwriting I guess. Is that ok coding? does it
> automatically close, or set to nothing
> the previous recordset that was used? And what is "nothing" really? How
> can a recordset be something and be
> closed?
>
> Any help would be appreciated. Thanks.
>
>