Squirm
Well-known member
After creating an OleDbDataReader by executing an OleDbCommand, how does one find out how many rows have been returned by the command? Failing that, is it possible to have the OleDbDataReader return to the first row after reading all the data? Obviously I can run the command again, but Im hoping there is an easier way, as there was in ADO.
I did try the .RecordsAffected property, but that always returns 0, and according to the help, returns how many records were affected by an UPDATE INSERT or DELETE operation. This leaves me wondering why it is a property of the OleDbDataReader which is for reading data, not updating it (as far as I can tell).
Code:
Dim Reader As OleDbDataReader
Dim RunCmd As New OleDbCommand(sCommand, Con)
Dim i As Int32
Con.Open()
Reader = RunCmd.ExecuteReader(CommandBehavior.Default)
Do While Reader.Read
i += 1
Loop
Now have recordcount in i, but have to requery to get back to the first row!
I did try the .RecordsAffected property, but that always returns 0, and according to the help, returns how many records were affected by an UPDATE INSERT or DELETE operation. This leaves me wondering why it is a property of the OleDbDataReader which is for reading data, not updating it (as far as I can tell).