how to move record forward or backward

  • Thread starter Thread starter hui
  • Start date Start date
H

hui

hi all

I have got a datareader by sqlcommand, now I wanna move forward or backward,
but I don't find first,last,prior and next methods. How can I do it?

thanks for your suggestion.

hui
 
to the best of my knowledge you will not be able to do this using a
datareader as it is foward only. You should consider using a DataAdapter and
DataSet
using the Fill method of a DataAdaptor. Post if you need further help.
 
A DataReader has a "Read" method which advances you to the next record as
well as returning a Boolean value indicating if there is a next record to
move to. You can not back up as a DataReader is a Read Only, Forward Only
mechanism.
 
thank you first.

I am newbie to c#. could you show me some example codes about how to move
record cursor with DataAdapter and Dataset?

hui
 
You use a DataAdapter to get a copy of the data you need brought into your
application and stored in a DataTable. The DataTable is made up of rows and
each row has its Items (columns). By iterating through rows and looking at
an item in a row, you can get and set data in your DataTable.

Now, a DataTable could be just one in a collection of DataTables. For this
reason, there is another object called a DataSet. A DataSet has a Tables
collection, which holds the previously mentioned DataTable object(s).
 
Back
Top