Navigate through Dataset

  • Thread starter Thread starter Paolo Taverna
  • Start date Start date
P

Paolo Taverna

Hi all

I am changing from VB and ADO 2.7 to C# and ADO.NET .
The Recordset Object from ADO 2.7 has a Method "next" .
Is there a similar Method when i am using a Dataset
perhaps in the Datatables or Datarows ?

Is it possible to navigate through a Dataset like
Recordset from ADO 2.7 ?

Best Regards
Paolo Taverna
 
Hello,

You have to know that two type of object can be used in
place of the recordset. It depends of what type of access
to the database you need.

First : you need a fast forward only reader that you will
keep a very short time : this is the sqldatareader (ex:Web
Page)
Second : you want to get a local xml-based representation
of your database - with ability to update the DB or
serialize in XML : this is the dataset.

You can use both for databinding.

Boris
 
Hello Boris

Thank you for Response. I want to use the Dataset Object because
i need the update, insert and delete functions.

Now i am missing a .next Method für navigating through the Datarows
in the Dataset. Something where i can set the position of a cursor or
something like that. (ADO 2.7 rs.next)

Best Regards
Paolo Taverna
 
You can access the rows in a DataTable by using a standard FOR loop, or by
using a FOR EACH ... NEXT loop.

Private Sub PrintRows(myDataSet As DataSet)
' For each table in the DataSet, print the values of each row.
Dim thisTable As DataTable
For Each thisTable In myDataSet.Tables
' For each row, print the values of each column.
Dim myRow As DataRow
For Each myRow In thisTable.Rows
Dim myCol As DataColumn
For Each myCol In thisTable.Columns
Console.WriteLine(myRow(myCol))
Next myCol
Next myRow
Next thisTable
End Sub

*I took that example from the VS.NET documentation.

~Greg
 
Hi all

Thank you for Response. I found now what i need.
With the Syntax Dataset.Datatable.Rows[nPos] it's possible to
set the Position of a Row manually.

Thank you for the help
Paolo Taverna
 
Back
Top