Close and free up object references

Posted: August 8, 2008 in ASP

While we’re on the topic of good coding techniques, I thought I would remind everyone to close and free up object references once they are done using them.

I tend to type in the commands to kill the object right after I create the object, and then start coding between them.

<%
Dim objConn, objRS
Set objConn = Server.CreateObject(“ADODB.Connection”)
objConn.ConnectionString = …
objConn.Open

Set objRS = objConn.Execute(“…”)

objRS.Close
Set objRS = Nothing

objConn.Close
Set objConn = Nothing
%>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s