IDataReader Problem

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top