[thelist] DBCon to SQL good/bad practice

Joshua Olson joshua at waetech.com
Mon Nov 24 07:14:29 CST 2003

----- Original Message ----- 
From: "John Dobson" <j.dobson at find-a-part.com>
Sent: Monday, November 24, 2003 4:35 AM

> If you are making DB connections to a database such as SQL, should
> you close any connection you open?  Is it bad practise to leave them open?

This will depend on your environment.  Some environments, such as CF, use
pooled connections and you have no control as to whether or not the
connections are opened or closed.  Since you ask the question, I assume that
you can control it... for example, using ASP.

Generally, it is a good idea to close ASAP and connections you open.  Keep
in mind that it is expensive to open a connection (and reopen, naturally) so
do as much of the work in one connection, close it, then don't reopen it, if

There are some tricks you can do in ASP to help with closing the connection
sooner.  Example: GetRows... it'll take a recordset and dump it VERY QUICKLY
to an array for you.  After this you can safely close the connection and
still use the data.  I'm positive that other languages have similar

IOW, yes, it's good practice (spelling!!) to close the connection.

Joshua Olson
Web Application Engineer
WAE Tech Inc.

More information about the thelist mailing list