none
Data Navigation without grid, need help RRS feed

  • Question

  • Hi

    Does anyone know what is the equivalent of  VB6  Recordset.movenext in C# without using a datagrid.

     

    I have used the Currencymanager.position but it seems to work only when we bind controls to it.

     

    What if I only want to navigate through records in DataSet at the BACK END only? I dont want to show any Grids or Controls on the form.

     

    Thanks.

    Monday, June 9, 2008 5:59 PM

All replies

  • Because a DataTable object is always in memory, ADO.NET does not require cursor access. ADO.NET uses array access instead.

    In C#, a DataSet has a collection of DataTables and a DataTable has a collection of DataRows. You could do not need to use MoveNext to navigate it. You use code as follows to navigate a DataTable.

     

    foreach(DataRow dr in dt.Rows)
    {

    int id = (int)dr["Id"];

    string name = (string)dr["Name"];

    }

     

    For more information, you could visit http://support.microsoft.com/kb/310372/en-us. It is a KB article with the title "DataTable and DataView do not include MoveFirst, MoveLast, MoveNext, and MovePrevious navigation methods". It is just the article describing your question.

    Wednesday, June 11, 2008 5:17 AM
  • Thanks

    Friday, June 13, 2008 4:42 AM
  • If I solved your problem, would you please make my answer as "answerer"? Thanks,

     

    Sunday, June 15, 2008 11:07 AM