通过在datagridview中选择行从数据库sql删除数据 [英] delete data from database sql by select row\s in datagridview

查看:92
本文介绍了通过在datagridview中选择行从数据库sql删除数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello world ...

在我的程序中,我放了一个按钮和一个datagridview,我想要:如果用户在(Datagridview)中选择任何单元格,然后按我创建的按钮,则从数据库中删除同一行(sql express 2008).为了成功实现此目的,我需要写下该按钮的代码是什么.

谢谢

解决方案

这些链接将教您如何选择行(2种不同的方法)

通过单击行在Gridview中选择行 [ http://www.geekzilla.co.uk/view9FC28EE6-ACB0-4F51-BFE4- 38B0B10134D5.htm [ ^ ]

现在,如果选择了一行,则可以在按钮单击事件内编写delete命令,并从gridview的选定行中获取行ID,以提供删除命令的条件.


Hello world...

In my program, I puted one button and one datagridview ,and I want : If the user select any cell in the (Datagridview) and then press the button that I created, deletes the same row from the database(sql express 2008). What is the code that I need to write down the button in order to achieve this successfully.

thank you

解决方案

the links will teach you, how to select row, (2 different approches)

Select a Row in a Gridview with a Click on Row[^]

http://www.geekzilla.co.uk/view9FC28EE6-ACB0-4F51-BFE4-38B0B10134D5.htm[^]

Now, if a row is selected, you can write delete command inside your button click event and get the row ID from the selected row of the gridview to supply in where condition of your delete command.


这篇关于通过在datagridview中选择行从数据库sql删除数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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