使用linq从datagridview更新数据库 [英] Update database from datagridview with linq
本文介绍了使用linq从datagridview更新数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从datagridview更新我的数据库,但是虽然代码编译了,但是没有保存更改。
基本上:
1)将datagridview绑定到查询,
2)对datagridview上的数据进行更改,
3)使用cellendedit捕获更改并更新数据库。
请查看下面的代码。
对于这么简单的问题很抱歉,但是我一直在网上搜索并且没有找到使用Linq的解决方案。
我尝试了什么:
I'm trying to update my database from a datagridview, but although the code compiles, the changes aren't saved.
Basically:
1)bind datagridview to a query,
2)make changes to the data on the datagridview,
3)use cellendedit to capture change and update database.
Please take a look at the code below.
Sorry for such a simple question, but I've been trawling the net and haven't found a solution using Linq that works.
What I have tried:
private void grdBOOK_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
using (lnkTRADERDataContext DATActx = new lnkTRADERDataContext())
{
grdBOOK.EndEdit();
DATActx.SubmitChanges();
}
}
推荐答案
浏览链接: C#教程:添加,删除,并编辑DataGridView中的行 [ ^ ]
这篇关于使用linq从datagridview更新数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文