Local database inserts not being stored

前端 未结 2 335
北海茫月
北海茫月 2021-01-23 05:47

This is probably a stupid mistake of me.. but I can\'t seem to understand it.

I\'ve created a new, empty C# Windows Forms application.

I added a Database (Based

相关标签:
2条回答
  • 2021-01-23 06:07

    Your database file is listed in the project with this property

     Copy to destination directory = Copy Always
    

    If this is true then every time you restart the project a fresh (empty) copy of the database file is copied from the project directory to the output directory (BIN\DEBUG or BIN\RELEASE) overwriting the database file used in the previous run. You could avoid this changing the property to Copy Never or Copy if newer

    0 讨论(0)
  • 2021-01-23 06:17

    The answer given by steve keeps copying the database over the existing one, which results in removing all data.

    I've managed to fix this by putting "Copy Always" on, then in the explorer move the database to a different location and add it to the project. This way the database will never be overwritten and can be used in the program!

    (However, this will probably raise a issue if/when I publish the project to another computer)

    0 讨论(0)
提交回复
热议问题