Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Asp; is a close good enough?

Status
Not open for further replies.

unseth

Programmer
Sep 10, 2000
31
US
set mycon = Server.CreateObject("ADODB.Connection")
mycon.Open "mydb", "", ""
set results = mycon.Execute(sql)

.... process recordset results ...

mycon.close

--------------

is that the proper way to close out the page (I'm using ASP)
i've seen people follow the mycon.close with a

set mycon = nothing

is this necessary? also should something be done to the recordset (results in this case) to free it up?

I want to make sure i'm not leaving any residue behind.

thanks [sig][/sig]
 
You should close out the entire connection (recordset included) in this manner...

Code:
rs.Close   'Close the recordset 
cn.Close   'Close the connection
Set rs = Nothing    'Remove the recordset object from memory
Set cn = Nothing    'Remove the connection object from memory

Basically you need to close the connection to the database (frees up db resources) and remove the objects that are no longer in use (frees up memory). On a side note, if you need to perform another query against the same database then just close the recordset. This will keep the resource intensive connection procedure from occurring unnecessarily.

Good luck
Rob [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top