How to navigate recordset in C#?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QmVybmFyZCBLaW0=?=

    How to navigate recordset in C#?

    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.mo venext,
    adorecordset,mo vefirst...etc. Please help me out.
  • sloan

    #2
    Re: How to navigate recordset in C#?



    The ado.net is only similar to ado in name.

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

    Google this:



    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 Kim" <BernardKim@dis cussions.micros oft.comwrote in message
    news:5F17AE36-0CA5-457D-9F8A-FF1695FB2438@mi crosoft.com...
    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.mo venext,
    adorecordset,mo vefirst...etc. Please help me out.

    Comment

    • Nicholas Paldino [.NET/C# MVP]

      #3
      Re: How to navigate recordset in C#?

      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 DataRowCollecti on, which implements the
      IEnumerable interface, so you can also do this:

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


      --
      - Nicholas Paldino [.NET/C# MVP]
      - mvp@spam.guard. caspershouse.co m

      "Bernard Kim" <BernardKim@dis cussions.micros oft.comwrote in message
      news:5F17AE36-0CA5-457D-9F8A-FF1695FB2438@mi crosoft.com...
      >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.mo venext,
      adorecordset,mo vefirst...etc. Please help me out.

      Comment

      Working...