المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : why do Update method of SqldataAdapter not work?



C# Programming
10-06-2009, 06:02 PM
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