N. America: (800)876-3101 | World: +44 (0) 1-344-386-367

Adding Connection Pooling in ADO.NET Applications

A connection pool is created in the process of creating each unique connection string that an application uses. When a pool is created, it is populated with enough connections to satisfy the minimum pool size requirement, which is set by the Min Pool Size connection string option. If an application is using more connections than Min Pool Size, the data provider allocates additional connections to the pool up to the value of the Max Pool Size connection string option, which sets the maximum number of connections in the pool.

When a DbConnection object is requested by the application calling the DbConnection.Open() method, the connection is obtained from the pool, if a usable connection is available. A usable connection is defined as a connection not currently in use by another valid DbConnection object that has a matching distributed transaction context (if applicable).

If the maximum pool size has been reached and no usable connection is available, the request is queued in the data provider. The data provider waits for the value of the Connection Timeout connection string option for a usable connection to return to the application. If this time period expires and no connection becomes available, the data provider returns an error to the application.

IMPORTANT: Closing the connection using the Close() method of the DbConnection object adds or returns the connection to the pool.

 

Prev: "Using Integrated Windows (NTLM) Authentication"

Next: "Removing Connections from a Pool"

Email Print Share

Connection Pooling in ADO.NET Applications

Tutorial: Connection Pooling in ADO.NET Applications Would you rather have the PDF version of this Tutorial? No Problem!

Click here to download the PDF version of Connection Pooling in ADO.NET Applications.