Click to See Complete Forum and Search --> : DataTable probelm, can't add new rows.


dky1e
July 18th, 2002, 12:16 PM
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?

pr4242
July 18th, 2002, 01:59 PM
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.

franc2
July 30th, 2002, 02:00 AM
shouldn't be there ImportRow ( row2 ) instead of ImportRow ( row )