clearing connection pool

  • Thread starter Srinivas Kollipara
  • Start date
S

Srinivas Kollipara

Hi,
in my C# project it uses 24 sql connections, i am clearing all the
conncetions whenever an error occurs and when i see in the performance
monitor for that pool i can still see all those 24 connections sitting over
there. so i am wondering how to clear the connection pool in C#. can anyone
suggest me in this. i need to do that programmatically. thanks in advance.
srinivas
 
A

Amit

ADO.NET uses connection pooling so even if you're closing your connections
in the code, the framework will keep them open for a while (until the
connection lifetime ends). As far as I know, currently there's no way to
force closing of actual connections to the database (other than disabling
connection pooling totally which is not recommended). I believe next version
of ADO.NET will provide the ability to clear the connection pools.
-Amit
 
S

Sahil Malik

Srinivas,

In .NET 1.1 you cannot clear the connection pool. And that is not such a big
deal because eventually they will close out or be reused per application
demands. The problem is when the SQL Server reboots and all your connections
that your side thinks are open and will throw weird errors now.

In .NET 2.0 however, the connection pool is cleared for you at the first
instance of such an error, so you do get this error once, but only once.
Alternatively, the SqlConnection object provides you with methods to clear
all connection pools or clear connection pool per connectionstring should
you choose to do so manually.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
S

Srinivas Kollipara

thanks for your help
srinivas
Amit said:
ADO.NET uses connection pooling so even if you're closing your connections
in the code, the framework will keep them open for a while (until the
connection lifetime ends). As far as I know, currently there's no way to
force closing of actual connections to the database (other than disabling
connection pooling totally which is not recommended). I believe next version
of ADO.NET will provide the ability to clear the connection pools.
-Amit
 
S

Srinivas Kollipara

thanks for your help
srinivas

Sahil Malik said:
Srinivas,

In .NET 1.1 you cannot clear the connection pool. And that is not such a big
deal because eventually they will close out or be reused per application
demands. The problem is when the SQL Server reboots and all your connections
that your side thinks are open and will throw weird errors now.

In .NET 2.0 however, the connection pool is cleared for you at the first
instance of such an error, so you do get this error once, but only once.
Alternatively, the SqlConnection object provides you with methods to clear
all connection pools or clear connection pool per connectionstring should
you choose to do so manually.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top