Reputation: 21
What happens if SQL connection pool opening and closing continuously in SQL Server? If anyone knows, please tell me.
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLDbConn"].ConnectionString);
SqlConnection.ClearPool(con);
Upvotes: 0
Views: 357
Reputation: 754258
You should check out the freely available MSDN documentation on the topic, which you could easily find with any of your favorite search engines....
E.g.
Here, the documentation says:
Only connections with the same configuration can be pooled. ADO.NET keeps several pools at the same time, one for each configuration. Connections are separated into pools by connection string, and by Windows identity when integrated security is used. Connections are also pooled based on whether they are enlisted in a transaction.
So why the connection pool is system-wide per server, there are several pools active at the same time.
Upvotes: 1
Reputation: 172378
I would advise you to use the using
statement
using (SqlConnection connection = new SqlConnection("..."))
{
}
By this you dont have to worry about closing the connection once the query is executed and the resources are managed automatically.
Upvotes: 0