C# 和 MS Access 数据库(更新)
我在 Windows 窗体 应用程序。 org/wiki/C_Sharp_%28programming_language%29" rel="nofollow noreferrer">C#,在我为保存按钮编码的表单上从我的 MS Access 数据库“inspro”创建了一个 C# 数据源:
try
{
this.Validate();
this.entitiesBindingSource.EndEdit();
this.entitiesTableAdapter.Update(this.iNSPRODataSet.Entities);
MessageBox.Show("Update successful");
}
catch (System.Exception ex)
{
MessageBox.Show("Update failed");
}
我得到消息框显示“更新成功”,但是当我签入 Access 时,没有任何更新。 我该如何解决这个问题?
I created a Windows Forms application in C#, created a data source in C# from the my MS Access database 'inspro' on the form I coded for the save button:
try
{
this.Validate();
this.entitiesBindingSource.EndEdit();
this.entitiesTableAdapter.Update(this.iNSPRODataSet.Entities);
MessageBox.Show("Update successful");
}
catch (System.Exception ex)
{
MessageBox.Show("Update failed");
}
I get the message box that says "Update successful", but when I check in Access, nothing is updated. How do I fix this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它可能与 EndEdit() 错误有关,该错误已捕获了许多其他。 如果它移动了焦点,这可能就是为什么你看不到你期望的保存的原因。
另一种可能性,请阅读本页底部的评论,它与移动到调试文件夹的 MDF 副本有关,从而有效地覆盖更改。
{编辑} 正如 Julien 所指出的,我提到的第二篇文章引用了 MDF(SQL Server),并且访问将是 MDB,但那里的理论仍然是合理的。 检查包含的文件是否设置为复制到输出目录。
It could be related to the EndEdit() bug that has caught many others. If it moves the focus, that could be why you're not seeing the save you're expecting.
Another possibility, read the comments at the bottom of this page, it has to do with a copy of the MDF moving to the debug folder, effectively overwriting the changes.
{EDIT} As pointed out by Julien, the second article I mentioned references an MDF (SQL Server), and access would be a MDB, but the theory there is still sound. Check to see if the included file is set to copy to output directory.