i am using the OleDbDataReader to read a column from an Access database and i want to be able to use the same reader to read the column again in the same function because i am doing some comparison between 2 databases and some times the identical records in the databases are not in the same order so i’ve to loop through the database until i find the specified record then compare.
questions are
is there a function to get the current row index of an OleDbDataReader?
and how do i reset the OleDbDataReader to the first row?
You can’t reset the reader to the start because it is designed for forward-only reading.
There are a couple of other ways to approach this kind of problem:
If the set of data you are comparing is reasonably sized and you are comparing on one field, you could cache the data from one database in a keyed object, such as a generic dictionary. Then, as you are reading data from the second database, you could fetch the details from the dictionary based on the key and perform the comparison that way.
You could issue standalone queries for each record in one database to see if there is a match in the second database rather than having nested readers.