C#:App:How to navigate through records in a dataset/datatable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • senthilnova
    New Member
    • Nov 2007
    • 7

    C#:App:How to navigate through records in a dataset/datatable

    hi
    i have a form with First,Next,Prev ,Buttons.
    i had populated a datatable with datas .Now i need to navigate through the records , can any body help me how to achieve this.

    Code:
                   conn = new SqlConnection(connstr);
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(sqlAllCustomers, conn);
                    SqlDataAdapter adpt = new SqlDataAdapter(cmd);
                    DataTable dtCust1 = new DataTable("CustomerDatTab");
                    adpt.Fill(dtCust1);
    thanks in adv
    sk
  • PareshRathod
    New Member
    • Mar 2007
    • 28

    #2
    Hello,

    You can retrieve the particular row of datatable wirh the index of row as datarow.
    for e.g.,

    dtCust1.Rows[0][0].ToString();

    This will return the first element of first row.
    You can navigate by adding and substracting the first 0.

    Just xpand your logic you will find the way...

    Paresh

    ds.


    Originally posted by senthilnova
    hi
    i have a form with First,Next,Prev ,Buttons.
    i had populated a datatable with datas .Now i need to navigate through the records , can any body help me how to achieve this.

    Code:
                   conn = new SqlConnection(connstr);
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(sqlAllCustomers, conn);
                    SqlDataAdapter adpt = new SqlDataAdapter(cmd);
                    DataTable dtCust1 = new DataTable("CustomerDatTab");
                    adpt.Fill(dtCust1);
    thanks in adv
    sk

    Comment

    • senthilnova
      New Member
      • Nov 2007
      • 7

      #3
      hi
      paresh
      Thanku its working fine.

      also one more doubt, is this the best way than using the CurrencyManage?
      since in my search a way of using the Currency manager to navingate recs.

      thanks
      sk

      Comment

      Working...