After an indeterminate period of time, your web site may stop working with the following 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.
Cause:
This error is caused by SQL Connections being left open in the web site code. After a while a large amount of open sql connections will build up until a limit is reached and the web site stops working.
Solution:
Ensure that all SQL Connections are closed after use. The recommended approach is to use the SQLConnection object within a Using statement. For example
Using conn as new SQLConnection
'Process queries here
End Using
Note:
SQLConnection objects need to be placed in a Using statement in addition to the SQLCommand object. Disposing the SQLCommand object may not close the underlying connection so SQLCommand.Connection also needs to be disposed.