Reset DataReader

rfazendeiro

Centurion
Joined
Mar 8, 2004
Messages
110
Hi to all,

I have an excel where i read the information to a listview. I connect to the excel file through OleDb and put it in a OleDbDataReader.

Now i have 2 processes that i run with the information. The 1rst one i read each row and confirm if certain information is in the excel. Then in the 2nd process I re-read the information and transform it.

My problem is that in the 2nd processe i dont what to query the excel file again so i reuse the DataReader of the 1st process, but it seems that the DataReader is in the last record and does not enter in the While. So how can I "reset" the DataReader to the first record?
 
rfazendeiro said:
Hi to all,

I have an excel where i read the information to a listview. I connect to the excel file through OleDb and put it in a OleDbDataReader.

Now i have 2 processes that i run with the information. The 1rst one i read each row and confirm if certain information is in the excel. Then in the 2nd process I re-read the information and transform it.

My problem is that in the 2nd processe i dont what to query the excel file again so i reuse the DataReader of the 1st process, but it seems that the DataReader is in the last record and does not enter in the While. So how can I "reset" the DataReader to the first record?

In my opinion you can't, if you read the msdn documentation you will see that the IDatareader interface meaning also the oledbdatareader and I quote: "Provides a means of reading one or more forward-only streams of result sets obtained by executing a command at a data source, and is implemented by .NET Framework data providers that access relational databases."

So I think it is not possible to do so, I would recommend storing your query in a DATASET which gives you more options in that directions.

Greetz
 
Back
Top