数据更新问题,我在前台更新了数据,但在后台没有更改。。。!!!!!!!!

Caolh 2004-11-05 02:52:19
数据更新问题,我在前台更新了数据,但在后台没有更改。。。!!!!!!!!
private void btnSave_Click(object sender, System.EventArgs e)
{

try
{

// End the Current edit. if you do not do this, when the user makes a
// change and then clicks the Save button prior to stepping to another
// records, the changes will not be propagated.

this.BindingContext[dtEmployeeInfo].EndCurrentEdit();

// Update the database with the changes made to the local resident DataSet.

da.Update(this.dtEmployeeInfo);



MessageBox.Show("Database successfully updated.",
"Custom Formatting Handler Demo", MessageBoxButtons.OK,
MessageBoxIcon.Information);

}
catch(Exception exp)
{

MessageBox.Show("There was an error when attempting to update " +
"the database: " + exp.Message,
this.Text, MessageBoxButtons.OK,
MessageBoxIcon.Error);
}

}
...全文
181 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Caolh 2004-11-05
  • 打赏
  • 举报
回复
按保存老是提示:
“其他信息: 当传递具有已修改行的 DataRow 集合时,更新要求有效的 UpdateCommand。”
为什么啊?!是否还要一个cmd写一个更新语句来更新呢,能帮写一个简单一点的例子吗,如果分不够可再加 TKS
zhaolee 2004-11-05
  • 打赏
  • 举报
回复
對,
要AcceptCahnges()後才是真正的到數據庫更新的。
xiaohutushen 2004-11-05
  • 打赏
  • 举报
回复
update后要接受改变。
this.BindingContext[dtEmployeeInfo].AcceptChanges();
不一定正确,具体是什么你再看

111,092

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧