OleDbDataReader "Closed" Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
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.
__________________________________
 
Back
Top