Problem when inserting data into SQL Compact by ADO.Net Entity Framework

泪湿孤枕 提交于 2019-12-12 01:35:43

问题


        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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!