更新时间:2023-12-03 11:00:16
如果表模式相同,则可以在代码中使用Marge方法。而不是将表添加到您的数据集。
If table schema is same you can use Marge method in your code. than add table to your data-set.
DataTable ONdt = new DataTable();
DataTable OFFdt = new DataTable();
string strsql = "SELECT * FROM **serverA_table**";
ONda = new SqlDataAdapter(strsql, ONcon);
ONds = new DataSet();
ONda.Fill(ONdt);
strsql = "SELECT * FROM serverB_table";
OFFda = new SqlDataAdapter(strsql, OFFcon);
OFFds = new DataSet();
OFFda.Fill(OFFdt);
OFFdt.Merge(ONdt);
// Than add it to your Dataset
OFFds.Tables.Add(OFFdt);