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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database Connection

Status
Not open for further replies.

vyper78

Programmer
Feb 5, 2004
30
0
0
AU
I'm hoping a discussion can be started on the following situation that I face in my program.

Many times throughout my program, I need to query the database for whatever reason. Each time I do this, I open a new connection and after I get the results, close the connection. Are all these open and closing of the db connection just overhead? Should I open the connection when the program loads and close when it finishes, or would that create too much overhead?

I'm bascially looking for advice as to the "correct" method (ie: what you guys do) when writing a program.
 
Open connections are expensive, and should only be open when necessary. So, your intuition is correct. Open and close the connections.

HTH

Bob
 
thank god for that - I was going to dred having to go through the code to remove all the "opens" and "closes".

Thankyou for the response.

V.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top