ExecuteReader requires an open and available Connection. The connection's curren

  • Thread starter Thread starter Lyuba
  • Start date Start date
L

Lyuba

Hi,
I'm having problem with database connection in my asp.net
application. It's some kind of mistery. It
throws "ExecuteReader requires an open and available
Connection. The connection's current state is Closed. "
exception some times. I'm sure that in my code everything
fine and my connection is open. If I refresh the page
after this error pups up, it gets back to normal.

Some time ago I came accross KB article stating that this
is microsoft BUG, but it's not there anymore.

Does any one know what might be wrong. I'm using SQL
server as database.

Thank you

Lyuba
 
Lyuba said:
Hi,
I'm having problem with database connection in my asp.net
application. It's some kind of mistery. It
throws "ExecuteReader requires an open and available
Connection. The connection's current state is Closed. "
exception some times. I'm sure that in my code everything
fine and my connection is open.

Well we aren't so sure.
Perhaps you could develop a little test case that demonstrates the problem.


David
 
Lyuba:

It could be a bug, but that'd be the last thing I'd look at. Right before
you fire your ExecuteReader Code, try a if (myConn.State <>
ConnectionState.Open){cn.Open();} There are a lot of places that you could
declare a connection and open it, then depending on how you handle post
backs, a post back could occur and it could be closed. Another thing that
could be happening is that Another reader is holding that connection and the
other reader isn't closed yet.

I'd exhaust these paths before looking at the bug angle b/c at least in my
experience, I have code that executes readers in ASP.NET thousands of times
a day on average , seen it under 1.0 and 1.1, and never had a problem that I
didn't accidentally cause.

Have you stepped through it with the debugger btw? If not, check the
connection.state beforehand.

Good Luck,

Bill
 
Thank you for your reply.
I'll try these.
-----Original Message-----
Lyuba:

It could be a bug, but that'd be the last thing I'd look at. Right before
you fire your ExecuteReader Code, try a if (myConn.State
 
Back
Top