views:

56

answers:

2
        DatabaseEntities de = new DatabaseEntities();
        Income income = de.Incomes.CreateObject();            
        income.Id = de.Incomes.Max(f => f.Id) + 1;            
        income.Person = Users.SelectedValue.ToString();
        income.Value = value;
        income.Unit = Unit.SelectedValue.ToString();
        income.Description = Desc.Text;
        de.Incomes.AddObject(income);
        de.SaveChanges();           

I have used the code section above to insert an Income object into SQL Compact database after that i have used the following statement to bind data to a DataGridView:

        IncomeGridView.DataSource = de.Incomes;

I saw the new data but after I closed my program I did not see the new data in table. Can anyone explain me?

+1  A: 

Possibly this - http://erikej.blogspot.com/2010/05/faq-why-does-my-changes-not-get-saved.html

ErikEJ
Great help ErikEj!
Linh
Great help ErikEj! because I have used the SQL Compact so each time I debug my program the *.sdf file is copied to the Debug folder by default and my program work with the copy database. I resolved my problem by set the absolute path to the database file in the application config file.
Linh
A: 

linh ...may i know which actual path we should try for...the path that our .sdf file copied to debug folder or the path .sdf file originally belongs to?? i have the same problem for few days probably with the code diffrent than urs. when application runs my insert/update works fine, n after closing n re debuging the update values shows too. only problem is that there is no any updates in original table in database. plz sir can u describe me easily bexause im new with mobile application. thank u!

sameer
I have never developed the mobile application but I think it also need application config file like desktop or web application. You try to modify connection string in the application config file reference to the path .sdf file originally.
Linh