views:

394

answers:

3

Here is the error we are getting. We moved app and db servers to x64 from 32-bit. Framework 2.0 service pack 2 is installed on the servers.

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.

Here is some code for DataAccess that returns a value from inside the Try block:

 public string GetSomething()
        { var a = String.Empty; 

            try 
            {
               // loop through the datareader 

                return "some data"; 
            }

            finally
            {
                reader.close(); 
            }

            return whatever; 
        }

And here is some code that opens and manages the connection:

public DBHelper(IDbCommand command) 
     {

      this.command = command;

      if (command.Connection.State == ConnectionState.Open)
      {

       shouldCloseConnection= false;
      }
      else
      {

       command.Connection.Open();
       shouldCloseConnection= true;
      }   
     }
A: 

Not a direct answer, but check out the Activity monitor and look at connections that are open for the applicaiton. Maybe the timeout setting in your previous install was set shorten causing the connections to get forced closed by SQL before the pool filled.

Chris Coneybeer
In the activity monitor it says that most of the connections are sleeping. I assume that means they are in the pool waiting to be used.
azamsharp
A: 

Try using

SqlConnection.ClearAllPools()

and see if this is really a connection pool problem.

Pierre-Alain Vigeant
+2  A: 

A) make sure your min pool size is big enough. Maybe something like 20 or 30.

B) Be careful you're disposing of objects properly. I learned that for instance when you use an IDataReader to get stuff from a database, you should do

using (IDataReader rdr = ...) {

}

That way no matter what (including an error) the rdr will be disposed of. Anyway sometimes pool issues are caused by not disposing of database connections properly.

Josh Warner-Burke
Turns out it was a connection leak in one of the base libraries.
azamsharp