Rows count in the DataReader


  • Please ,

    Can some one help me to know the code to get records(rows) count in the datareader

    Thanks for your help


    Thursday, July 06, 2006 8:46 AM


  • Hi,

    DataReader itself doesn't provide this information. The way to retrieve the row count  would be scanning the returned data stream by using a counter:

    Dim counter As Integer = 0

    While reader.Read()
    counter += 1
    End While

    or executing SELECT COUNT(*) query to get the row count, before executing the reader.


    Thursday, July 06, 2006 9:12 AM