Connection poolling

  • Thread starter Thread starter Gilles Nambert
  • Start date Start date
G

Gilles Nambert

Hi,

Despite somme reading (including doc, Reflector, etc.), i dont't really
understand wich is the best method between Close and Dispose (or perhaps
the both) to get pooling with SQL Server with a well defined connection
string ?

If any body have some idea or a good pattern to close a connection ?

Best regards
Gilles
 
Gilles,

Close, Dispose and Using are functionally equivalent ways of closing the
connection.

With the .net data provider for SQL Server, connection pooling is managed
automatically so nothing additional should need to be done by you.

In what way is connection pooling not working for you?

Kerry Moorman
 
Consider that the ADO.NET Connection objects are simply "connectiods" to
pooled connections which are maintained by the provider's connection pooling
mechanism (CPM). When they are closed (or disposed) the connection pool
"connection" is simply marked as "reusable" and a timer starts. If another
request for the same connection string is passed to the provider, the oldest
resuable connection is reactivated. If 4-8 minutes passes without another
request the connection is physically closed by the CPM.

The need for pooling really varies based on the architecture of your
application. Lots of perfectly functional Windows Forms applications
(especially those that want to manage server-side state on their own) don't
pool at all. ASP or similar application live and die based on how well the
pool is managed.

See Chapter 9 of my book.

Gilles Nambert said:
Hi,

Despite somme reading (including doc, Reflector, etc.), i dont't really
understand wich is the best method between Close and Dispose (or perhaps
the both) to get pooling with SQL Server with a well defined connection
string ?

If any body have some idea or a good pattern to close a connection ?

Best regards
Gilles

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
 
Back
Top