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;"
;
Article ID: 1540, Created: December 9, 2013 at 12:27 AM, Modified: December 9, 2013 at 12:31 AM