Why saving changes to a database fails?

后端 未结 2 1285
予麋鹿
予麋鹿 2020-11-21 05:51

I have following C# code in a console application.

Whenever I debug the application and run the query1 (which inserts a new value into the database) and then run que

2条回答
  •  臣服心动
    2020-11-21 06:39

    Committing changes / saving changes across debug sessions is a familiar topic in SQL CE forums. It is something that trips up quite a few people. I'll post links to source articles below, but I wanted to paste the answer that seems to get the best results to the most people:


    You have several options to change this behavior. If your sdf file is part of the content of your project, this will affect how data is persisted. Remember that when you debug, all output of your project (including the sdf) if in the bin/debug folder.

    • You can decide not to include the sdf file as part of your project and manage the file location runtime.

    • If you are using "copy if newer", and project changes you make to the database will overwrite any runtime/debug changes.

    • If you are using "Do not copy", you will have to specify the location in code (as two levels above where your program is running).

    • If you have "Copy always", any changes made during runtime will always be overwritten


    Answer Source

    Here is a link to some further discussion and how to documentation.

提交回复
热议问题