//////////////// cs
public DataTable
Merge_Tables(DataSet ds, string sortConditions, string
sortType)
{
DataTable dt = new
DataTable(), Sqldt = new DataTable();
try
{
if (ds.Tables.Count > 0)
{
dt = ds.Tables[0].Copy();
for (int
i = 1; i < ds.Tables.Count; i++)
{
DataTable dtMain =
ds.Tables[i].Copy();
for (int
r = 0; r < dtMain.Rows.Count; r++)
{
dt.ImportRow(dtMain.Rows[r]);
}
}
}
dt.AcceptChanges();
if (sortConditions != "")
{
DataView dv = dt.DefaultView;
dv.Sort = "" +
sortConditions + " " + sortType + "";
Sqldt = dv.ToTable();
}
else
{
Sqldt = dt.Copy();
}
Sqldt.AcceptChanges();
}
catch (Exception)
{
}
return Sqldt;
}
No comments:
Post a Comment