简体   繁体   English

以可视方式构建DataGridView控件的插入,更新和删除功能

[英]Visually Build Insert, Update, and Delete Functions for DataGridView Control

QUESTION: 题:

What is the proper way to insert , update , and delete statements visually inside of Visual Studio for a Data Grid View control such as we do with the select statement? 在Data Studio View控件中可视化地在Visual Studio内部直观地插入更新删除语句的正确方法是什么(例如我们使用select语句所做的方法)?


BACKGROUND: 背景:

I've found many tutorials online showing how you can programmatically insert, update and delete records via the data found in the data grid when it's in edit mode however none that show the built in, "visual" functions such as we have with the select query. 我在线上找到了很多教程,这些教程显示了当处于编辑模式时如何通过数据网格中的数据以编程方式插入,更新和删除记录,但是没有一个显示内置的“可视”功能,例如select查询。

Now when connecting to the database, Visual Studio generates a DataSet in which we can actually go in under SqlTableAdapter and find our select query that was generated for us but when we add an insert query (which is possible!) into that interface it shows up along side our select query such as here: 现在,当连接到数据库时,Visual Studio会生成一个数据集,我们可以在其中实际进入SqlTableAdapter,并找到为我们生成的选择查询,但是当我们在该接口中添加一个插入查询(可能的话)时,它将显示以及我们的选择查询,例如:

SqlTableAdapterQuery

However when going back to the data grid view and selecting "Add Query" the new insert query doesn't show up: 但是,当返回数据网格视图并选择“添加查询”时,新的插入查询不会显示:

向数据网格视图添加新查询 选择现有查询数据网格视图

I've found the solution. 我找到了解决方案。

To visually add Insert, Update, and Delete statements to a data grid follow the steps above and in "TableAdapter Configuration Wizzard" select advanced options as shown below. 要将可视化的Insert,Update和Delete语句添加到数据网格中,请按照上述步骤操作,并在“ TableAdapter Configuration Wizzard”中选择高级选项,如下所示。


高级选项-表适配器配置向导

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM