Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changes to Access database do not persist when running app in Visual Studio

I am creating a library application in Visual Studio 2010 Professional and Access 2010. I bind the Access database to Visual Studio. When I fill out the fields and click submit I can see the new record in the DataGridView, but when I close the application the new record is not saved and I have to input the record again.

Can somebody help me to know why when I input the new record through the application the record is not saved in the database?

like image 687
Bart g Avatar asked Dec 25 '22 19:12

Bart g


1 Answers

It is a very common situation. You have your database file (the MDB or ACCDB file) listed between your project items. If you click on this file and look at the properties window you will see a property called Copy to the output directory. If this property is set to Copy Always then every time you start a debug session the database file listed in your project items is copied by VS in the output directory (usually BIN\DEBUG). Of course this copy doesn't contain the records inserted in your last debug session and you think that your previous insert has failed.

Setting this property to Copy If Newer, the mentioned behavior will happen only if you change the database schema manually.

Setting this property to Copy Never, will let you manually copy the database file.

like image 143
Steve Avatar answered Dec 28 '22 12:12

Steve