[quoted text, click to view] James wrote:
> Quick question about closing recordsets and connection objects.
> We're in the process of rewriting a TON of bad code. None of it is
> even remotely tabbed properly, it's impossible to read half the time
> and it never closes connection objects or recordsets. Unfortunately,
> I've been assigned the task of closing them. I assume I'm just doing:
>
> recordset.close
> Set recordset = Nothing
>
> conn.close
> Set conn = Nothing
>
> ...whenever it's no longer needed. I guess that my question is, how
> do I need to handle redirects within a page. Should I close/set to
> nothing before a redirect,
Yes. Any code that appears after a redirect will not be executed.
[quoted text, click to view] > or by the page losing "focus", will these
> objects be released anyway?
Maybe. It's the times that they don't close automatically that cause the
memory leaks
[quoted text, click to view] >
> Are there any general rules of thumb that might save me some time
> going through the 1,000,000+ lines of code?
>
Close and destroy child objects (recordsets, command objects) before closing
and destroying parent objects (connections). Note: command objects can't be
closed, only destroyed.
Or, the "Things I learned in kindergarten" version:
if you open it, close it
if you create it, destroy it
Sorry, there's nothing i've said here that will save you any time.
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.