Home All Groups Group Topic Archive Search About

OleDbDataReader "Closed" Problem

Author
4 Jul 2006 8:28 PM
Alex Maghen
I've made some changes to the structure of my code around a bunch of my pages
which access the database and now I'm getting a very occasional error at
DataBind() time saying that my OleDbDataReader object is already closed.

I'm working on debugging this but, in the mean time, I wanted to see if
someone could explain to me *when* a DataReader object gets closed, because
this comfuses me. I'm assuming that the DataReader object gets closed and
becomes inaccessible when the Database Connection object is closed. Fine. But
other their other circumstances when the DataReader gets closed even when the
database Connection is still open?

Alex

Author
4 Jul 2006 9:49 PM
W.G. Ryan eMVP
Alex - are you using a COmmandBehavior?  Close connection will close the
underlying connection when the reader closes.  If the connection closes then
the reader can't operate.  If you're using Databind, I believe it closes the
reader when it's done, lemme look and make sure - I know I remember reading
something about this a while ago.
Show quote
"Alex Maghen" <AlexMaghen@newsgroup.nospam> wrote in message
news:A392538E-53E0-4EF3-AB70-10D7AA14698F@microsoft.com...
> I've made some changes to the structure of my code around a bunch of my
> pages
> which access the database and now I'm getting a very occasional error at
> DataBind() time saying that my OleDbDataReader object is already closed.
>
> I'm working on debugging this but, in the mean time, I wanted to see if
> someone could explain to me *when* a DataReader object gets closed,
> because
> this comfuses me. I'm assuming that the DataReader object gets closed and
> becomes inaccessible when the Database Connection object is closed. Fine.
> But
> other their other circumstances when the DataReader gets closed even when
> the
> database Connection is still open?
>
> Alex
Author
4 Jul 2006 9:51 PM
William (Bill) Vaughn
Are you testing the DataReader.HasRows before binding?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Show quote
"Alex Maghen" <AlexMaghen@newsgroup.nospam> wrote in message
news:A392538E-53E0-4EF3-AB70-10D7AA14698F@microsoft.com...
> I've made some changes to the structure of my code around a bunch of my
> pages
> which access the database and now I'm getting a very occasional error at
> DataBind() time saying that my OleDbDataReader object is already closed.
>
> I'm working on debugging this but, in the mean time, I wanted to see if
> someone could explain to me *when* a DataReader object gets closed,
> because
> this comfuses me. I'm assuming that the DataReader object gets closed and
> becomes inaccessible when the Database Connection object is closed. Fine.
> But
> other their other circumstances when the DataReader gets closed even when
> the
> database Connection is still open?
>
> Alex

AddThis Social Bookmark Button