The timeout period elapsed prior to obtaining a connection from the pool

Error:
"Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached."

Discription
When you open an SQL Connection object, it always takes from an available pool of connections. When you close the connection, asp.net will release the connection to the pool of connections so that next connection object can use it.

If you open connections with out closing them and when the pool reaches maximum connections, it will throw the specified error. Make sure you are not opening connection inside loop, if you open connection make sure you are closing it immedietly after you execute the query.

Solution:
You can try the following things

1. Always close your connection in the finally block

2. Increase pool size like in your connection string

string connectionString = "Data Source=localhost; Initial Catalog=Northwind;" +
"Integrated Security=SSPI; Min Pool Size=10; Max Pool Size=100";

3. Don't use pooling at all

string connectionString = "Data Source=localhost; Initial Catalog=Northwind;" +
"Integrated Security=SSPI; Pooling=false;";

Error:
"Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached."

Discription: 
When you open an SQL Connection object, it always takes from an available pool of connections. When you close the connection, asp.net will release the connection to the pool of connections so that next connection object can use it.

If you open connections with out closing them and when the pool reaches maximum connections, it will throw the specified error. Make sure you are not opening connection inside loop, if you open connection make sure you are closing it immedietly after you execute the query.

Solution:
You can try the following things

1. Always close your connection in the finally block

2. Increase pool size like in your connection string
string connectionString = "Data Source=localhost; Initial Catalog=Northwind;" +
"Integrated Security=SSPI; Min Pool Size=10; Max Pool Size=100";

3. Don't use pooling at all
string connectionString = "Data Source=localhost; Initial Catalog=Northwind;" +
"Integrated Security=SSPI; Pooling=false;";

  • Email, SSL
  • 307055 Users Found This Useful
Was this answer helpful?

Related Articles

The query has been canceled because the estimated cost of this query () exceeds the configured threshold.

Error:The query has been canceled because the estimated cost of this query () exceeds the...

Powered by WHMCompleteSolution