思路话语

。Arlen:思想有多远你就能走多远...

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;
        }

posted on 2009-03-13 15:56  Arlen  阅读(1427)  评论(0编辑  收藏  举报

导航