开发者

Entity Database not committing add or save changes c# winform

开发者 https://www.devze.com 2023-03-21 06:13 出处:网络
This is a simple winform im creating that when you click a button it will gather data from a combo box and then add data to a database here is the button event code.

This is a simple winform im creating that when you click a button it will gather data from a combo box and then add data to a database here is the button event code.

private void button1_Click_1(object sender, EventArgs e)
{
    Database1Entities5 enti开发者_如何学编程ties = new Database1Entities5();
    int personOneID = entities.People.Where(p => p.Name == _PersonOne).FirstOrDefault().PersonID;
    int personTwoID = entities.People.Where(p => p.Name == _PersonTwo).FirstOrDefault().PersonID;
    int amount = _Amount;
    int TypeID = entities.Types.Where(t => t.Name == _Type).FirstOrDefault().TypeID;
    Money m = Money.CreateMoney(personOneID, personTwoID, TypeID, _Amount, DateTime.Now, CommentTextBox.Text);
    entities.Moneys.AddObject(m);
    entities.SaveChanges();
   // 
}

when i click the button nothing happens, during debuging the Money m is created fine; i have no idea whats going on, any help would be appreciated.

0

精彩评论

暂无评论...
验证码 换一张
取 消