合并两个数据集的方法
通过代码看本质
string sql = "select * from world";
if (Conn.State != ConnectionState.Open) Conn.Open();
if (myConnection.State != ConnectionState.Open) myConnection.Open();
DataSet ds = new DataSet();
DataSet ds1 = new DataSet();
AseDataAdapter dater = new AseDataAdapter(sql, Conn);
dater.AcceptChangesDuringFill = false;
dater.Fill(ds);
OleDbDataAdapter odater = new OleDbDataAdapter(sql, myConnection);
OleDbCommandBuilder custCB = new OleDbCommandBuilder(odater);
odater.Fill(ds1);
ds1.Merge(ds);
odater.UpdateCommand = custCB.GetUpdateCommand();
odater.InsertCommand = custCB.GetInsertCommand();
odater.DeleteCommand = custCB.GetDeleteCommand();
DataTable updTable = ds1.Tables[0];
odater.Update(updTable.Select(null, null, DataViewRowState.Added));
本文地址:http://www.45fan.com/bcdm/73992.html