将行从一个数据表复制到另一个数据表? [英] Copy rows from one Datatable to another DataTable?
本文介绍了将行从一个数据表复制到另一个数据表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将特定行从 DataTable 复制到 c# 中的另一个 Datable?会有不止一行.
How can I copy specific rows from DataTable to another Datable in c#? There will be more than one row.
推荐答案
foreach (DataRow dr in dataTable1.Rows) {
if (/* some condition */)
dataTable2.Rows.Add(dr.ItemArray);
}
以上示例假设dataTable1
和dataTable2
具有相同的列数、类型和顺序.
The above example assumes that dataTable1
and dataTable2
have the same number, type and order of columns.
这篇关于将行从一个数据表复制到另一个数据表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文