编辑datagridview并将其保存到数据库 [英] edit datagridview and save it to database

查看:134
本文介绍了编辑datagridview并将其保存到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!
我在winform上有一个datagridview,其中从ms Access数据库填充表的记录.我希望datagridview是可编辑的,所以我启用了datagridview的编辑.但是对gridview单元格或行所做的更改未保存在数据库中,因此当我再次运行该应用程序时,它不会在datagridview中显示已编辑的记录.

如何使datagrid视图可编辑,并且在编辑记录后必须将其保存在数据库中.

感谢

Hello!!
I have a datagridview on my winform in which i m populating the records of a table from ms access database. I want the datagridview to be editable , so i enabled editing of datagridview. But the changes made to gridview cell or row are not saved in database, hence when i run the application again it doesn''t shows the edited records in datagridview.

How can i make datagrid view to be editable and after editing records must be saved in database.

Thanks

推荐答案

查找此 CodeProject [ ^ ]文章


只需使用:

simply use:

OleDbCommandBuilder build = new OleDbCommandBuilder(adapter);


用于构建upadate查询并在保存记录按钮上单击事件,请写以下行:


for building the upadate query and on save record button click event write the below line:

adapter.Update(dt);


其中adapter是OleDbDataAdapter的对象,而dt是DataTable的对象

谢谢.


where adapter is a object of OleDbDataAdapter and dt is object of DataTable

Thanks.


尝试
自动将DataGridView行保存到SQL Server数据库 [
Try
Auto Saving DataGridView Rows to a SQL Server Database[^]


这篇关于编辑datagridview并将其保存到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆