You may run into the following error in .NET when connecting to a database:
System.InvalidOperationException: 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.
This is most likely because you have exceeded the maximum pool size for your SQL connection. In ADO.NET, connection strings are pooled by default. To avoid this error, you can use one of the following solutions:
1. Clean up your code! It is especially important to call Close when you finish with a pooled
connection to release it back into the pool.
2. Raise the Max Pool Size. If you are getting this because you actually have more than
50 people hitting the same page at the same time, then you can set the minimum and
maximum pool sizes by adding to your connection string code similar to the following:
"min pool size=1; max pool size=50"
3. Disable connection pooling. Add the following to your connection string to disable connection pooling:
"pooling=false"
However, Microsoft highly discourages you disable connection pooling for performance reasons. See the following URL for more information on connection pooling in
ADO.NET:
http://samples.gotdotnet.com/quickstart/howto/doc/adoplus/connectionpooling.aspx