TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Bruce Lam
NA
3
0
why do Update method of SqldataAdapter not work?
Oct 5 2009 11:46 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 <= 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]);
Reply
Answers (
3
)
Question: .Net/Oracle application best design when building sql command parameters
How to retrieve data from database onto asp table??