DAAB, Enterprise Lib, connection timeout.

G

Guest

Hi there!
I'm using the Enterprise Library ver. 2.0 for all data access in my web
application but have problems to free up resources though I close readers as
stated in the documentation. The error message I get is;

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

I have configured my connection pool to have max 5 connections and at least
1 open connection (this for testing purposes). My typical data access code
look like the following;

public bool Authenticate(string username, string password) {
SqlDataReader reader = null;
try {
Database db = DatabaseFactory.CreateDatabase();
DBCommandWrapper wrapper = db.GetStoredProcCommandWrappe("Authenticate");
wrapper.AddInParameter("username", DbType.String, username);
wrapper.AddInParameter("pwd", DbType.String, password);
using(reader = (SqlDataReader) db.ExecuteReader(wrapper)) {
if(reader.Read()) {
return true;
}
}
} catch(ConfigurationException ce) {
//TODO Use the Enterprise library Exception handling framework.
throw ce;
}
return false;
}

I have also tried to close the reader object in a try - finally block
instead of using the "using" statement, no difference!

In the above code, do you see anything that could cause the problem. It's
not necessary to close the underlying connection explict, or is it?

Best regards Niclas
 
L

Luke Smith

I came across the same problem and fixed it by adding the following in a
finally block which fixed the problem

if (reader != null)
{
reader.Close();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top