[Turn] to copy one line to another DataTable DataRow

 Source Address: http: //www.cnblogs.com/pains/archive/2007/11/22/969003.html
 
Here are two ways to copy one line to another DataTable DataRow directly Add to be wrong, "this trip already belongs to another table", in fact, before you know how to do, when to use each time, or confused, this time put them down.
1. DataRow.ItemArray
the DataTable the DataTable new new = T ();
the DataRow = R & lt t.NewRow ();
; r.ItemArray = oldRow.ItemArray
t.Rows.Add (R & lt);

2. with DataTable.ImportRow ()
T. ImportRow (oldRow);
Here are two ways to copy one line to another DataTable DataRow directly Add to be wrong, "this trip already belongs to another table", in fact, before you know how to do, when to use each time, or confused, this time put them down.
1. DataRow.ItemArray
the DataTable the DataTable new new = T ();
the DataRow = R & lt t.NewRow ();
; r.ItemArray = oldRow.ItemArray
t.Rows.Add (R & lt);

2. with DataTable.ImportRow ()
T. ImportRow (oldRow);

Guess you like

Origin www.cnblogs.com/haizine/p/11585698.html