Reputation: 105
Guys I have a problem in saving data in my database.
The system I am developing saves data in the database and displays the data in the datagrid and that runs smoothly, but the problem is whenever I restart or reboot the application the data disappears and the database was again empty but the data entered directly in the database using show table data, didn't disappear.
Am I missing something in my program?
Upvotes: 3
Views: 2840
Reputation: 41
Do the following steps:
Upvotes: 4
Reputation: 13582
I had the same problem long time ago. I remember that the data that I would enter in a execution would vanish on the next execution and it was because the local database file was copied (and hence overwritten) on each execution.
I solved it by setting Copy to Output Directory
property of my local database to Do not copy I suppose, test it, if it's not Do not Copy then it may be Copy Always.
But I'm sure my (same) problem solved this way.
Hope it works in your case too.
EDIT: Eman, do the following steps. It should solve your problem.
1.right click on your abc.mdf database file from solution explorer
2.hit properties
3.change COPY TO OUTPUT DIRECTORY
4.run your application, add a row, exit app, run it again
5.if row is lost, goto step 1, else exit
Upvotes: 2