Home All Groups Group Topic Archive Search About
Author
9 Jun 2006 4:37 AM
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

Author
9 Jun 2006 5:11 AM
Cor Ligthert [MVP]
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


Show quoteHide quote
"Anuradha" <anurad***@lankaequities.com> schreef in bericht
news:%236fiu63iGHA.1600@TK2MSFTNGP04.phx.gbl...
> 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
>
>
Author
9 Jun 2006 5:19 AM
GhostInAK
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

Show quoteHide quote
> 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
>