Why are database records lost when I'm debugging the 开发者_开发知识库winforms application? When I start the debugging app, records are saved into the database, but when it is restarted, all of the database records are lost and the database tables are empty. How can I debug an application without losing the data?
Are you sure the database is actually being updated? Have you checked with something other than the program you're debugging?
Is there perhaps a transaction that you are not committing?
Edit in reply to your comment
It sounds like maybe you need to change the properties of your database file in your Visual Studio solution - turn off "Copy to output folder".
It sounds like you might be adding the records in a transaction and then not committing it. When you exit from the application (debugging session), the transaction is rolled back, and all your changes are lost.
Click on database. Go to properties. Select "Copy if newer".
精彩评论