1

当我使用 datagridview 和SubmitChanges()

private void Form1_Load(object sender, EventArgs e)
{
    this.book_infoDataGridView.DataSource = bookstore.book_info;
    BindingSource bds=new BindingSource();
    bds.DataSource = this.bookstore.book_info;
    this.book_infoBindingSource = bds;
    this.book_infobindingNavigator.BindingSource = bds;

}      

private void save_Click(object sender, EventArgs e)
{
   this.book_infoBindingSource.EndEdit();
    bookstore.SubmitChanges();
}
4

1 回答 1

0

我相信你正试图.SubmitChanges()从你的数据中DataGridView

    private void save_Click(object sender, EventArgs e)
    {
        using (var bookstoreContext = new yourContext())
        {
            var b = (BookClass)bds.Current;
            var book = bookstoreContext.Products.Single(c => c.BookId == b.BookId); //or .First()
            book.BookName = b.BookName;
            book.BookInfo = b.BookInfo;
            bookstoreContext.SubmitChanges();
        }
    }
于 2013-02-08T07:05:54.873 回答