It seems folks have lost the ability to generate old style COBOL/RPG reports using modern day languages.
I often see code using DataReaders that relies on a count of records. So an additional aggregrate query is present when it need not be.
In most circumstance this code needs to know if there is another record available or not. In other words, tell me if I'm at the last record so I can display a record separator.
A simple algorithm would be as follows:
Dim available As Boolean = rdr.Read()
While available
DisplaySearchRecord(rdr)
available = rdr.Read()
If available Then DisplaySeparator()
End While
Please, do not use COUNT(*) or a datatable/dataset when a simple change in algorithm will suffice.