1
votes

I'm having Trouble with the following Error:

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

It seems that the error is in the following code block:

da = new SqlDataAdapter(command);
command.CommandTimeout = 100;
da.Fill(dt);
conn.Close();
return dt;
2
Probably should wrap the command and the connection in a using statement. That could help with your connections leaking.Kevin Up

2 Answers

0
votes

It's hard to say with such a small amount of code in your question but this error can occur when you're not disposing of your db connection objects properly. The "using" statement may help you out of this problem. There is a SO issue with the same error message and code examples here: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. which may help.

0
votes

When you open any connection and not close after completion then it will show you above error. because there is app pool size limit, after limit exceeds it will show you error.

So try to close connection after completion of method. Or for the time being you can set max pool size in web.config file as 1000 or more.