views:

205

answers:

2

I'm working on someone else's project that makes heavy use of tableAdapters. The site works but It regular adds an entry in the Event log :

"ExecuteReader requires an open and available Connection. The connection's current state is connecting. "

The site doesn't throw an exception though unless there is high traffic (5+ requests per second) the exception is the same, pointing to this line of code:

this.Adapter.Fill(dataTable);

Stack trace: at System.Data.SqlClient.SqlConnection.GetOpenConnection(String method) at System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command)

How can i stop this error? Thanks.

Turns out i was only getting half the picture, the error, when it would throw an error is:

"There is already an open DataReader associated with this Command which must be closed first."

A: 

I would say you're probably using the same connection for multiple purposes and one of them is getting closed by another thread.

I'd recommend to add some tracing to figure out what's going on. It's hard to debug this kind of errors, the ones you only get when in production :(

sebastian
A: 

If seems like you have exceeded the allowed number of open connections to your database. This can be set in the connection string by giving values for the Min Pool Size and Max Pool Size values. I think the defaults are 0 for Min Pool Size and 100 for Max Pool Size, but I'm not sure.

Try to change them and see if it helps.

Rune Grimstad