FAQ: Why doesn’t the database seem to update when restarting an application after some changes?

Locked FAQ: Why doesn’t the database seem to update when restarting an application after some changes?

Locked

  • Saturday, April 11, 2009 6:10 PM
     
     

    Why doesn’t the database seem to update when restarting an application after some changes?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

All Replies

  • Saturday, April 11, 2009 6:11 PM
     
     Answered

    Usually, someone adds a database file (e.g. .mdb, .mdf, .sdf) as Data Source to a project, and creates a data access application. After inserting or updating data, if an application is restarted, the database does not seem to update.


    Cause:

    When you add Data Source, Visual Studio .NET maintains two copies of the database, one in the Project folder, and the other in the bin folder. Each time the application restarts, the former is copied to the latter.  Therefore, you get a clean copy.

     

    Solution:

    Right click on the database file in Solution Explorer -> Select Properties -> Set the "Copy to output directory" property value as "copy if newer".

     

    Related thread:
    http://social.msdn.microsoft.com/forums/en-US/vbgeneral/thread/f06363ee-0949-4204-b927-9684d1cfec6e

     

    For more FAQ about Visual Basic .NET General, please see Visual Basic .NET General FAQ

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.