Data Reader

  • Thread starter Thread starter Anuradha
  • Start date Start date
A

Anuradha

Dear Experts



How can I count how many records load to the Data Reader

And if I run while.dataReader.read() loop. will it automatically move to
the next record and loop pls help me



Best regards,

Anuradha
 
Anuradha,

You can do it in advance with a
"Select count from table ...........where..........."


integer Count = Cmd.ExecuteScalar(sqlString,conn)



(Be aware that while reading somebody else can remove a record)


I hope this helps,


Cor
 
Hello Anuradha,

The DataReader is analogous to a sql forward only cursor. So using strictly
a DataReader you can not determine the number of records fetched.
You can however count each record as you process it.. in which case you will
have a running total during processing and a grand total after processing.
If you need a grand total before processing (or during) then I would point
you towards a DataTable.

-Boo
 
Back
Top