[英]How to insert, update, and delete data from a database table using DataGridView?
I am using DataGridView
in VB Dot Net to show data from Database table in it. 我在VB点网中使用DataGridView
在其中显示数据库表中的数据。 I am able to show it. 我能够证明这一点。 Now I want to be able to update, delete, insert records in my database table when I make any changes in my DataGridView
grid on the click of a button. 现在,我希望能够通过单击按钮在DataGridView
网格中进行任何更改时,在数据库表中更新,删除,插入记录。
How do I achieve this? 我该如何实现?
(I am using ADODB as my connection object to connect to the database.) (我将ADODB用作连接到数据库的连接对象。)
Take a look at command fields. 看一下命令字段。 They offer a way to add Select, Edit, Delete to gridviews. 它们提供了一种将选择,编辑,删除添加到网格视图的方法。 Here is a link to documentation with a nice example at the bottom. 这是一个文档链接,底部有一个漂亮的例子。
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.commandfield(v=vs.110).aspx http://msdn.microsoft.com/zh-CN/library/system.web.ui.webcontrols.commandfield(v=vs.110).aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.