如何在 C# 中从 DB (*.mdb) 中删除一行
我有一个名为:Programs 的访问数据库 (.mdb),其中有一个名为:Data 的表。通过使用 DataGridView,我呈现了数据表中的数据。我想在运行时从 DataGridView 和数据库中删除一行。有谁知道如何做到这一点(使用 C#)?
我的另一个问题是,谁可以在我的数据库上运行查询?
谢谢!
I have an access DB (.mdb) named: Programs, with one table named: Data. By using the DataGridView I present the data from the table Data. I want to delete a row from the DataGridView and from the DB during runtime. Does anyone know how to do that (using C#)?
Another question I have is, who can i run queries on my DB?
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很简单。
我想在您的数据网格中您有一个复选框,通过选择您将能够选择要删除的行。假设您有一个提交按钮,因此在选择行后单击提交按钮。在按钮的点击事件中调用删除查询,说
delete from tblname where id = @id
[@id 是将要从网格传递的 id]之后,只需填充网格,例如
select * 来自 tblname
例如
Aspx 代码
提交按钮 cilck 事件的代码
希望这是有道理的。
Very simple.
I suppose in your datagrid you have a check box by choosing which you will be able to choose the rows that you want to delete. And assuming you have a submit button, so after choosing the rows click on the submit button. In the button's click event call the Delete query say
delete from tblname where id = @id
[@id is the id that will be passed from your grid]After that just populate the grid e.g.
select * from tblname
e.g.
Aspx code
Submit button cilck event's code
Hope this makes sense.