Does anyone have any insight on how I can get a count of the records
returned
after executing an ExecuteReader command? Something similar to the
.RecordCount property in Classic ASP?
Not natively. The DataReader is a connected object, so its record count is
not known until all the records have been read.
If you don't need to know the record count *before* you start reading the
records, you can simply increment a counter each time you read a record.
If you just want to know whether the DataReader contains records or not, use
its HasRows property (assuming you're using v1.1 of the Framework)
However, if you really need to know the number of records before you have
read them all, essentially you have two choices:
1) Return two recordsets, the first containing the number of rows e.g.
SELECT COUNT(*) FROM <table>
SELECT * FROM <table>
2) Use a DataSet...