views:

123

answers:

1

Hey,

How can I go back to the previous row using OleDbDataReader.

I know that DataReader just advance to the next row using DataReader.Read(), but how can I go back to the previous row. ???!!

+2  A: 

You can't. The DataReader API was specifically designed to only allow forward iteration. If you need the previous row, you should cache it yourself, or use something else (like dump the DataReader into a DataSet)

Matt Greer
why not change the API to allows forward iteration ?
dotNET
Because it is a very generic API, used for all kinds of data sources. For some data sources, keeping track of more than one row is very expensive (or maybe even impossible). If you want more than one row, the provided solution is to use a `DataSet`. If memory serves, it's `DataSet.Fill(dataReader)`
Matt Greer