records affected

S

simon

I have datareader. I filled it with data and also if I use rdr.has rows it
returns True.

If I use rdr.read and scroll over it, it works.

But if I wants to finds the records affected I always get -1.

rdr.RecordsAffected=-1

Why?

Regards,
Simon
 
G

Guest

Quote from .NET Documentation
"The number of rows changed, inserted, or deleted; 0 if no rows were
affected or the statement failed; and -1 for SELECT statements."

I believe that DataReader does not return recordcount because it provides
forward-only reading through result set.
 
M

Mark Rae

Quote from .NET Documentation
"The number of rows changed, inserted, or deleted; 0 if no rows were
affected or the statement failed; and -1 for SELECT statements."

I believe that DataReader does not return recordcount because it provides
forward-only reading through result set.

Correct. The DataReader has no notion of the number of records it contains -
only that it does or does not contain any records.
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top