将 DataTable t1 内容复制到 DataTable t2中
DataTable t2= new DataTable();
t2=t1.Clone();
for(int i=0;i<t1.Rows.Count;i++)
{
DataRow dr =t1.Rows[i];
t2.Rows.Add(dr.ItemArray);
}
注意点 将t1中的DataRow复制到t2中时;用dr.ItemArray;不然会报 “该列已在其他表中使用”的错误。
将 DataTable t1 内容复制到 DataTable t2中
DataTable t2= new DataTable();
t2=t1.Clone();
for(int i=0;i<t1.Rows.Count;i++)
{
DataRow dr =t1.Rows[i];
t2.Rows.Add(dr.ItemArray);
}
注意点 将t1中的DataRow复制到t2中时;用dr.ItemArray;不然会报 “该列已在其他表中使用”的错误。