IDataReader Problem

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

hi

..NET 3.5
Sql Server 2005

In my webproject I have this code:

while (reader.Read()) //reader = IDataReader
//process some logic here...

Yesterday I came across a bug in my webproject, I didn't know what caused
it. But after debugging my code for a while I've learned that "while
(reader.Read())" isn't 100% safe. My test data contained 3 rows. When the 3.
row is read the reader tryes to read the last row again. which throws an
exception.

I've put an Debug.Writeline in my code and had to send the output window the
ID column on each row in the resultset, that way I learned that the reader
was trying to read a row it already has read...

any suggestions?
 
Back
Top