如何在C Sharp中将datatable列从一个表复制到另一个表... [英] How to copy a datatable column from one table to another in c sharp...
本文介绍了如何在C Sharp中将datatable列从一个表复制到另一个表...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将一个数据表的动态选择的列复制到另一数据表.
I want to copy dynamically selected columns of one data-table to another data table.
推荐答案
.NET框架中的DataTable类将为您提供帮助.这是将PresentAddress表的列复制到PermanantAddress表的示例.
DataTable class in .NET framework will help you. Herez an example to copy the columns of PresentAddress table to PermanantAddress table.
DataTable PresentAddress = new DataTable();
DataTable PermanantAdress = new DataTable();
foreach (DataRow sourcerow in PresentAddress .Rows)
{
DataRow destRow = PermanantAdress.NewRow();
destRow["Name"] = sourcerow["Nam"];
destRow["Address"] = sourcerow["Addr"];
PermanantAdress.Rows.Add(destRow);
}
这篇关于如何在C Sharp中将datatable列从一个表复制到另一个表...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文