There are several reasons to have this error pop up on your website. The fix requires thorough analysis of the behavior.
First, check for DB code
Database access code must be within the 'using' block. In case this is not done, it may keep your database connections live even when your code is not performing any database transaction.
Check out for following in your data access layer
- If you have your own wrapper over any database library, the wrapper must inherit IDisposable. In the dispose method, it should close the database connections and explicitly assign 'null' to the database and related objects.
- Use the 'using' block at all places. If you are not using the 'using' block, use the try..catch..finally block
using (SqlConnection conn = new SqlConnection)
} // Connection is disposed and closed here, even if an exception is thrown[/sourcecode]or
SqlConnection conn = new SqlConnection(myConnectionString);
conn.Close(); // This line will get called in any case — success/failure
- If you are using DataReader, make sure you are creating the object of data reader from the database connection class, something likereader = databaseConnection.CreateReader();
[ad#between post content]
Second, check the Database Connection Timeouts
EXEC SP_CONFIGURE 'remote query timeout', 1800
EXEC sp_configureEXEC SP_CONFIGURE 'show advanced options', 1
EXEC sp_configureEXEC SP_CONFIGURE 'remote query timeout', 1800
Modify your connection string to add an application name to connect to database. You can even use a module identifier within your application to detect which module of your application is leaving the connections open
Data Source=myServer; Initial Catalog=myDB; User Id=myUsername; Password=myPassword; Application Name=myApp;
Then with a SQL query, you can find out the program name and the open connections
SELECT Program_name, count(*)
GROUP BY Program_name
ORDER BY count(*) desc
Though not really recommended, you can increase the pool size to 100 in the connection string and try it.