Results 1 to 2 of 2

Thread: DUBT when close ADO object

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005

    DUBT when close ADO object

    in unload me events i use:

    set = conn=nothing

    but this command destroy all opned recorset , or i need to use:

    set rs=nothing
    set rs1=nothing
    set = conn=nothing

  2. #2
    Join Date
    Feb 2006

    Re: DUBT when close ADO object

    Setting these to Nothing is rarely needed. But when you don't understand the scope of variables or object lifetime people often follow the blind rule given to ASP scripters to shut them up. Of course it could have negative consequences even there due to Connection Pooling semantics under ASP and similar scenarios.

    Most Recordsets are dependent upon either an external Connection object they are linked to, or an internal Connection object. So if you want to use a Recordset don't close its Connection. "Using" it includes things like committing pending updates it may be holding.

    Disconnected Recordsets are another scenario, but you don't seem to be using those here.

    So if you are trying to close everything up during Form_Unload you must usually deal with pending updates (if any), then close each Recordset, and finally close their common Connection. But it is rare that setting them to Nothing is necessary or useful. The reference variables go out of scope when the module they are declared in gets unloaded, and if the reference count goes to 0 as it normally would then the object gets deallocated.

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