C# 和 MS Access 数据库(更新)

发布于 2024-07-29 13:38:55 字数 575 浏览 2 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空‖城人不在 2024-08-05 13:38:55

它可能与 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文