简体   繁体   中英

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:

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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