CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002
    Posts
    121

    DataTable probelm, can't add new rows.

    Code:
    foreach( DataRow row1 in myTable.Rows )
    {
    DataRow row2= ds.Tables["myTable2"].NewRow();
    //do stuff to the row2, update it with data from row1
    ds.Tables["myTable2"].ImportRow( row );
    ds.AcceptChanges();
    }
    This code only adds one row to the "myTable2", even though there are multiple rows in myTable, and the program cycles thorugh the loop multiple times.

    What's the problem?

  2. #2
    Join Date
    Jan 2002
    Posts
    15
    Hi,
    I have used "ds.Rows.Add(newRow)" .
    I haven't used Import Row function, and I am no sure why it did not work.

  3. #3
    Join Date
    Jul 2002
    Posts
    10
    shouldn't be there ImportRow ( row2 ) instead of ImportRow ( row )
    Last edited by franc2; July 30th, 2002 at 08:18 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured