How to navigate recordset in C#?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have VC# 2005. I need to use ADODB instead with ADO.NET. I can open a
recordset. however, I can not navigate records in recordset. How can I
navigate records? What is the command line for adorecordset.movenext,
adorecordset,movefirst...etc. Please help me out.
 
The ado.net is only similar to ado in name.

Throw everything (most everything) you know about recordsets in ADODB.

Google this:
http://www.google.com/search?hl=en&q=IDataReader+DataSet+ADODB


and read about IDataReaders and DataSets.


IDataReader is a forward only "fire hose" way to read data.

DataSet puts all the data in memory at one time.

If you need to move between data, you'll need a dataset.

But its not .MoveFirst , .MoveNext stuff.


Start there, and then ask more specific questions later is my advice.
 
Bernard,

In ADO.NET, you have a datatable, which is pretty much the same as the
recordset. The DataTable exposes the Rows property, which uses a zero-based
index. Given that, you can do this:

for (int index = 0; index < dt.Rows.Count; ++index)
{
// Get the row.
DataRow row = dt.Rows[index];

// Work with the row here.
}

The Rows property returns a DataRowCollection, which implements the
IEnumerable interface, so you can also do this:

foreach (DataRow row in dt.Rows)
{
// Work with the data row.
}
 
Back
Top