//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); // 将DataRow添加到DataTable中
object[] obj = row.ItemArray;
DataRow rownew = tmp.NewRow();
rownew.ItemArray = obj;
tmp.Rows.Add(rownew);
}
return tmp;
}
DataRow[]转DataTable C#
于 2013-12-02 14:57:41 首次发布