问题
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:
Possibly this - http://erikej.blogspot.com/2010/05/faq-why-does-my-changes-not-get-saved.html
来源:https://stackoverflow.com/questions/3766596/problem-when-inserting-data-into-sql-compact-by-ado-net-entity-framework