datarow[]转换成datatable

来源:互联网 发布:域名的别名 编辑:程序博客网 时间:2024/05/01 03:30
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;
        }
原创粉丝点击