Sunday, March 11, 2012

connection from the pool

I build an asp.net 2.0 (VS 2005) web application and put it on the server. The installed SQL server is SQL server 2003. I get this error message when i keep the application running for 10 or 15 mins. "Timeout expired. The timeout period elapsed prior obtaining a connection from the pool. This may have occure because all pooled connections were in use and max pool size was reached."

I made the server timeout unlimited but the error keeps coming up after some time of openning the application. The application session time out redirects the user to the login page and doesn't throw an error like the one i mentioned above.

Any idea. Thanks in advance.

designstudio,

try increasing the number of connections in the pool. in your connection string, here is an example

conn.ConnectionString = "integratedsecurity=SSPI;SERVER=YOUR_SERVER;DATABASE=YOUR_DB_NAME;Min Pool Size=5;Max PoolSize=60;Connect Timeout=2;";

see where it says max pool size = ...have you tried that?


hope this helps -- jp

|||

jdingo is not online. Last active: 03-16-2007, 6:45 PMThanks jdingo,

I haven't tried that. I think it will work.

I'll let you know if it doesn't work.

|||

jdingo is not online. Last active: 03-16-2007, 6:45 PMThanks jdingo,

I haven't tried that. I think it will work.

I'll let you know if it doesn't work.

|||

You might also want to ensure that you really are closing all connections. The best way to ensure this is to use the 'using' statement in C#, or a try-finally combination where you explicitly close the connection in the finally block.

string connectionString = GetConnectionString(); // Gets the connection string in some way defined by youusing (SqlConnection connection =new SqlConnection(connectionString)){ connection.Open();// Do whatever needs to be doing. When the using-block is exited, the connection // objects Dispose() method will be called, ensure that the connection is returned // to the pool. Even if an exception occurs.}

No comments:

Post a Comment