Connection max pool size reached

asp.netiis-7web.config

i got the following error in my application.

"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. "

With out any idea i just changed compilation debug="true" to compilation debug="false" in web.config.

issue suddenly disappeared. is there any connection between compilation debug and pool size?

Best Answer

It looks like a connection leaking issue. It's important to always close / dispose connections after use. Otherwise they are not returned to the connection pool (or returned too slow).

Make shure you always have using statements with connections such as:

using (SqlConnection connection = new SqlConnection(connectionString))  
{  
    SqlCommand command = connection.CreateCommand();  

    command.CommandText = "mysp_GetValue";  
    command.CommandType = CommandType.StoredProcedure;  

    connection.Open();  
    object ret = command.ExecuteScalar();  
}  

More information here