From my understanding, .Net will pool SqlConnection objects where the connection string is the same by default. Will the connection still be pooled if I call the Dispose method?
This question is asked under the context of an ASP.NET application that at times makes many hits to the database in a single PageLoad event. I want the connections to be pooled, but would like confirmation that Closing and Disposing of the connection once the data operation is complete does not interfere with .NET’s handling of the connection pool.
When using connection pooling, closing a
SqlConnectionsimply tells the connection pool that you are done with it. The pool will then decide whether or not to actually close the connection, or to reuse it.From the MSDN docs: