Resource Use

Discussion in 'ASP General' started by MDW, Jul 26, 2003.

  1. MDW

    MDW Guest

    Theoretical question.

    If I create an recordset using the ubiquitous

    Set objRS = objConn.Execute(strSQL)

    I'm told that at the end of my code, I should set objRS
    back to nothing to release the resources it uses. That's
    all fine and good. My question is, if I create several
    different recordsets throughout the course of the ASP
    page, and (because I'm lazy) I want to re-use the name
    objRS....should I set it to nothing before I re-create it
    using a SQL statement? In other words, is there any
    appreciable performance/resource difference between these
    two scenarios?

    ' SCENARIO 1
    Set objRS = objConn.Execute(strSQL)

    ....

    Set objRS = objConn.Execute(strSQL2)
    ....

    Set objRS = objConn.Execute(strSQL3)
    ....

    Set objRS = objConn.Execute(strSQL4)

    ....

    Set objRS = Nothing

    ' SCENARIO 2
    Set objRS = objConn.Execute(strSQL)

    ....

    Set objRS = Nothing
    Set objRS = objConn.Execute(strSQL2)
    ....

    Set objRS = Nothing
    Set objRS = objConn.Execute(strSQL3)
    ....

    Set objRS = Nothing
    Set objRS = objConn.Execute(strSQL4)

    ....

    Set objRS = Nothing
    MDW, Jul 26, 2003
    #1
    1. Advertising

  2. MDW

    Bob Barrows Guest

    There's nothing lazy about re-using a variable.

    You only need to destroy it once at the end. It wouldn't be a bad idea to
    close the recordset before opening it on another SQL statement.

    Bob Barrows
    PS. You should always close the recordset before setting it to nothing.
    Ditto for the connection.

    MDW wrote:
    > Theoretical question.
    >
    > If I create an recordset using the ubiquitous
    >
    > Set objRS = objConn.Execute(strSQL)
    >
    > I'm told that at the end of my code, I should set objRS
    > back to nothing to release the resources it uses. That's
    > all fine and good. My question is, if I create several
    > different recordsets throughout the course of the ASP
    > page, and (because I'm lazy) I want to re-use the name
    > objRS....should I set it to nothing before I re-create it
    > using a SQL statement? In other words, is there any
    > appreciable performance/resource difference between these
    > two scenarios?
    >
    > ' SCENARIO 1
    > Set objRS = objConn.Execute(strSQL)
    >
    > ...
    >
    > Set objRS = objConn.Execute(strSQL2)
    > ...
    >
    > Set objRS = objConn.Execute(strSQL3)
    > ...
    >
    > Set objRS = objConn.Execute(strSQL4)
    >
    > ...
    >
    > Set objRS = Nothing
    >
    > ' SCENARIO 2
    > Set objRS = objConn.Execute(strSQL)
    >
    > ...
    >
    > Set objRS = Nothing
    > Set objRS = objConn.Execute(strSQL2)
    > ...
    >
    > Set objRS = Nothing
    > Set objRS = objConn.Execute(strSQL3)
    > ...
    >
    > Set objRS = Nothing
    > Set objRS = objConn.Execute(strSQL4)
    >
    > ...
    >
    > Set objRS = Nothing
    Bob Barrows, Jul 26, 2003
    #2
    1. Advertising

  3. MDW

    MDW Guest

    Thx for the info.


    >-----Original Message-----
    >There's nothing lazy about re-using a variable.
    >
    >You only need to destroy it once at the end. It wouldn't

    be a bad idea to
    >close the recordset before opening it on another SQL

    statement.
    >
    >Bob Barrows
    >PS. You should always close the recordset before setting

    it to nothing.
    >Ditto for the connection.
    >
    >MDW wrote:
    >> Theoretical question.
    >>
    >> If I create an recordset using the ubiquitous
    >>
    >> Set objRS = objConn.Execute(strSQL)
    >>
    >> I'm told that at the end of my code, I should set objRS
    >> back to nothing to release the resources it uses. That's
    >> all fine and good. My question is, if I create several
    >> different recordsets throughout the course of the ASP
    >> page, and (because I'm lazy) I want to re-use the name
    >> objRS....should I set it to nothing before I re-create

    it
    >> using a SQL statement? In other words, is there any
    >> appreciable performance/resource difference between

    these
    >> two scenarios?
    >>
    >> ' SCENARIO 1
    >> Set objRS = objConn.Execute(strSQL)
    >>
    >> ...
    >>
    >> Set objRS = objConn.Execute(strSQL2)
    >> ...
    >>
    >> Set objRS = objConn.Execute(strSQL3)
    >> ...
    >>
    >> Set objRS = objConn.Execute(strSQL4)
    >>
    >> ...
    >>
    >> Set objRS = Nothing
    >>
    >> ' SCENARIO 2
    >> Set objRS = objConn.Execute(strSQL)
    >>
    >> ...
    >>
    >> Set objRS = Nothing
    >> Set objRS = objConn.Execute(strSQL2)
    >> ...
    >>
    >> Set objRS = Nothing
    >> Set objRS = objConn.Execute(strSQL3)
    >> ...
    >>
    >> Set objRS = Nothing
    >> Set objRS = objConn.Execute(strSQL4)
    >>
    >> ...
    >>
    >> Set objRS = Nothing

    >
    >
    >
    >.
    >
    MDW, Jul 28, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    4
    Views:
    736
    walala
    Sep 12, 2003
  2. Earl Teigrob
    Replies:
    1
    Views:
    770
    Earl Teigrob
    Oct 31, 2003
  3. Dirc Khan-Evans
    Replies:
    1
    Views:
    893
    Karl Seguin
    Oct 17, 2005
  4. avishosh
    Replies:
    2
    Views:
    10,569
    avishosh
    Aug 8, 2004
  5. Heinrich Moser
    Replies:
    1
    Views:
    457
    Heinrich Moser
    Mar 27, 2008
Loading...

Share This Page