DataRow数组转换DataTable

public DataTable ToDataTable(DataRow[] rows)
{
if (rows == null || rows.Length == 0) return null;
DataTable tmp = rows[0].Table.Clone(); // 复制DataRow的表结构
foreach (DataRow row in rows)
tmp.Rows.Add(row.ItemArray); // 将DataRow添加到DataTable中
return tmp;
}

 

posted @ 2015-05-29 22:51  临冰听雪丶  阅读(448)  评论(0编辑  收藏  举报