下面兩個方法是DataRow複製一行到另一個DataTable的,直接Add會出錯“此行已屬於另一個表”。
1.用DataRow.ItemArray
DataTable t=new DataTable();
DataRow r=t.NewRow();
r.ItemArray=oldRow.ItemArray;
t.Rows.Add(r);
2.用DataTable.ImportRow()
t.ImportRow(oldRow);
下面兩個方法是DataRow複製一行到另一個DataTable的,直接Add會出錯“此行已屬於另一個表”。
1.用DataRow.ItemArray
DataTable t=new DataTable();
DataRow r=t.NewRow();
r.ItemArray=oldRow.ItemArray;
t.Rows.Add(r);
2.用DataTable.ImportRow()
t.ImportRow(oldRow);