0

Recently I work on SQL Server 2008 R2 database. I create database and attach .mdf file of same database in my application with some default data in it . Run application default data coming properly. Now I insert, update some data in my application and its works fine. But as I exit application and again run application lastly added and updated data get lost but default data coming proper as earlier. Please help. Why new

Ankush Madankar
  • 3,689
  • 4
  • 40
  • 74

2 Answers2

4

As mention by @Henk , @Microtechie , I scan my project folder and found there are 3 copies of .mdf file are there, 1st in project folder where code project([ProjectFolder ]) resides 2nd in [ProjectFolder]/bin/debug folder and 3rd in [ProjectFolder]/bin/release folder and suddenly solution to my que trigger in my mind. Problem not in multiple .mdf files in project folder, as I every time ‘Clean’ and ‘Build’ my solution new copy of .mdf file from [ProjectFolder] get copied into [ProjectFolder]/bin/debug folder, result in override of last .mdf file in same folder. Hence every time I build and run application only default data coming and last added and updated data get lost. Thanku all for your replies and precise answer..!

Ankush Madankar
  • 3,689
  • 4
  • 40
  • 74
-2

What kind of object do you load your .mdf file data into? It is likely that you need to save the changes in that object before closing the application.

Flipbed
  • 719
  • 9
  • 18
  • I used Entity Framework (.edmx). And every database statement is under 'using' store clause means as using scope end database connection get close. e.g `using(Mystore _store = new MyStore()) { // Database operations _store.SaveChanges(); }` – Ankush Madankar Jul 03 '13 at 09:43