By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,276 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,276 IT Pros & Developers. It's quick & easy.

Keep a few connections open all the time or open/close connections on the fly?

P: n/a

Just a quick question about connection management. My application will
never need more than 1 or 2 connections about at any given time. Also, I do
not expect many users to be connected at any given time. For efficiency, I
would like to keep connections alive throughout the lifetime of the objects
requiring them, rather than opening a new connection, executing code and
then closing it again. What is the most efficient way of doing this?
Should I perform the open/close or just one open when I create the object
and a close when I dispose of it?

Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Robin Tucker (r.******@thermoteknix.com) writes:
Just a quick question about connection management. My application will
never need more than 1 or 2 connections about at any given time. Also,
I do not expect many users to be connected at any given time. For
efficiency, I would like to keep connections alive throughout the
lifetime of the objects requiring them, rather than opening a new
connection, executing code and then closing it again. What is the most
efficient way of doing this? Should I perform the open/close or just one
open when I create the object and a close when I dispose of it?


First of all, what client library are you using?

Some client libraries, ADO and ADO.Net employs connection pooling, so
when you officially disconnects, the client library actually keeps the
connection around for some 60 seconds, in case you like to reuse it.
Connection pooling can be quite essential in web applications.

If you are writing a VB application and you know you will never have
any users connected, I don't see anything wrong in creating a connection
and keep the connection object alive as a global variable.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.