Connection Pool Control

Not all of the providers support connection pooling. The SQL Server and Oracle providers do. There was previously no way to programmatically clear the pool of open connections. The upcoming release of ADO.NET will include the ability to clear the connection pool in the SqlClient and OracleClient providers through static methods on the corresponding connection objects.

Connection Pool Control Sample Code

The following sample code demonstrates the use of the static methods to clear the connection pools:

// Clear all the pools
System.Data.SqlClient.SqlConnection.ClearAllPools();

// Clear a specific pool
SqlConnection dbconn = new SqlConnection();
dbconn.ConnectionString =
ConfigurationSettings.AppSettings.Get("ConnectionString");
SqlConnection.ClearPool(dbconn);

Comments