datetable合并成一个
程序员文章站
2022-06-02 13:39:19
...
tatetable 合并
public void
try
{
DataTable1 = ol.GetDataSetBySQL(sql, con).Tables[0];
DataTable2 = ol.GetDataSetBySQL(sqls, con).Tables[0];
DataTable newDataTable = DataTable1.Clone();
object[] obj = new object[newDataTable.Columns.Count];
for (int i = 0; i < DataTable1.Rows.Count; i++)
{
DataTable1.Rows[i].ItemArray.CopyTo(obj, 0);
newDataTable.Rows.Add(obj);
}
for (int i = 0; i < DataTable2.Rows.Count; i++)
{
DataTable2.Rows[i].ItemArray.CopyTo(obj, 0);
newDataTable.Rows.Add(obj);
}
if (newDataTable == null || newDataTable.Rows.Count == 0 )
{
context.Response.End();
}
else
{
string result = ParseJson.ToJsonX(newDataTable);
context.Response.Write(result);
}
}
catch (Exception e)
{
Trace.WriteLine(e.ToString());
}
}