This is my coding, DeleteComand and InsertComand work, but UpdateComand
not work, if change dap.AcceptChangesDuringFill is true, then
UpdateComand work, but Delete and Insert not work, please help me to
solve this problem as impossible as
DataSet dsLocal = new DataSet();
DataSet dsServer = scsiClass.getDS("SELECT * FROM [t_HR_Group]", "t_HR_Group");
SqlDataAdapter dap = new SqlDataAdapter("SELECT * FROM [t_HR_Group1]", con);
dap.MissingSchemaAction = MissingSchemaAction.AddWithKey;
dap.AcceptChangesDuringFill = false;
dap.UpdateCommand = cmd.GetUpdateCommand();
dap.DeleteCommand = cmd.GetDeleteCommand();
dap.InsertCommand = cmd.GetInsertCommand();
dap.Fill(dsLocal, "t_HR_Group");
SqlCommandBuilder cmd = new SqlCommandBuilder(dap);
dsServer.Merge(dsLocal, true, MissingSchemaAction.AddWithKey);
//dsServer.GetChanges();
int cn = dsServer.Tables[0].Rows.Count - 1;
for (int i = 0; i <= cn; i++)
{
DataRow dr = dsServer.Tables[0].Rows[i];
if (dr.RowState == DataRowState.Unchanged)
{
dr.SetAdded();
}
else
if (dr.RowState == DataRowState.Added)
{
dr.AcceptChanges();
dr.Delete();
}
}
int eff=dap.Update(dsServer.Tables[0]);
Loading
jimPosted Oct 20, 2009, 8:22 AM
Bruce LamPosted Oct 6, 2009, 1:58 AM
Mirko MeierPosted Oct 6, 2009, 12:45 AM