简体   繁体   English

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

[英]C# and MS Access database (updating)

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: 我用C#创建了一个Windows Forms应用程序,并用我为Access按钮编写的窗体上的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");
}

I get the message box that says "Update successful", but when I check in Access, nothing is updated. 我收到显示“更新成功”的消息框,但是当我签入Access时,没有任何更新。 How do I fix this problem? 我该如何解决这个问题?

It could be related to the EndEdit() bug that has caught many others . 它可能与EndEdit()错误有关,该错误引起了很多其他问题 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. 另一种可能是,请阅读本页底部注释 ,这与将MDF的副本移至debug文件夹有关,有效地覆盖了更改。

{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. {EDIT}正如Julien所指出的那样,我提到的第二篇文章引用了MDF(SQL Server),并且访问将是MDB,但是理论仍然很可靠。 Check to see if the included file is set to copy to output directory. 检查包含的文件是否设置为复制到输出目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM