clearpixel.gif

 

support index
 :: asp closing database connections 

 

clearpixel.gif

ASP - Closing Database Connections

How do I close my database connection in my ASP Scripts?

For every call in your scripts that reference the database, you must have a close command corresponding to each open command. This regulation is designed to protect the integrity of your site and your fellow clients' Websites, as well as the stability of the network.

There are only a limited number of connection lines and each time a connection is left open, excessive bandwidth and CPU is used. Thus we ask our clients to close their database connection to minimize memory leaks. Unless a close command (conn.close) is issued, your connection will not be automatically closed unless otherwise timed out by the server. Simply place this command at the end of your ASP scripts that call for an ODBC connection and you should be all set!

An example of using the close command can be found at the following link:

http://support.microsoft.com/support/kb/articles/q165/6/71.asp?LNG=ENG&SA=ALLKB

Notice there is a conn.open command that opens a connection to the database in the following piece of code:

Set Conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.RecordSet")
Conn.Open dsn, dbuser, dbpass

Also, at the bottom of the script there is a conn.close command that closes the connection:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' % Make sure to close the Result Set and the Connection object
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RS.Close
Conn.Close
%>
</TABLE>
<%
end if
end if
%>

search our site
clearpixel.gif clearpixel.gif

copyright render-vue 1999 - © all rights reserved