DataTable.Merge 时出现DataType不致 int32 int64
DataTable1的sql:
select distinct a.*,t.id as serverid,b.id as deptid,....
DataTable2的sql:
select distinct a.*,0 as serverid, 32 as deptid,...
在调用dt1.Merge(dt2)的时候,由于两个serverid字段类型不一致,一个int32,一个int64,导致无法Merge。
用importRow的方式就可以合并了:
private DataTable MergeTable(DataTable dest, DataTable source)
{
DataRow[] sourceRows = source.Select();
for (int i = 0; i < sourceRows.Length; i++)
{
dest.ImportRow(sourceRows[i]);
}
return dest;
}