Resource Use

M

MDW

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
 
B

Bob Barrows

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.
 
M

MDW

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.




.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top