0
        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?

Linh
  • 1,024
  • 2
  • 16
  • 28

1 Answers1

2

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

ErikEJ
  • 40,951
  • 5
  • 75
  • 115
  • 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 Sep 22 '10 at 06:42