DataGrid选择,删除和更新操作 [英] DataGrid Select,Delete and Update Operation

查看:93
本文介绍了DataGrid选择,删除和更新操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜!首先,我需要知道如何在Datagrid快捷方式上选择删除和​​更新操作。



我填写这样的数据



 sql_cmd = sqLiteConnection1.CreateCommand(); 
string CommandText = 选择*来自PLU ;
DA = new SQLiteDataAdapter(CommandText,sqLiteConnection1);
DS4.Reset();
DA.Fill(DS4);
DT = DS4.Tables [ 0 ];
dataGridView4.DataSource = DT;
sqLiteConnection1.Close();





DA:DataAdapter,DS4:DataSet,DT:DataTable



有人可以帮助我吗?

解决方案

你的问题形式不完善,而且很难回答它。 。



引用:

DataGridView控件 [ ^ ]提供了一种以表格格式显示数据的强大而灵活的方法。您可以使用DataGridView控件显示少量数据的只读视图,也可以缩放它以显示非常大的数据集的可编辑视图。



您可以通过多种方式扩展DataGridView控件,以便在应用程序中构建自定义行为。例如,您可以以编程方式指定自己的排序算法,并可以创建自己的单元格类型。您可以通过选择多个属性轻松自定义DataGridView控件的外观。许多类型的数据存储可以用作数据源,或者DataGridView控件可以在没有绑定数据源的情况下运行。



更多关于:DataGridView类 [ ^ ]

DatagridView控件中的DataEntry [ ^ ]



所以,你不能选择删除和​​更新Datagrid快捷方式操作 - 无论它意味着什么。



要操纵数据,你需要使用 ADO.NET [ ^ ]。

Quote:

ADO.NET将数据访问与数据操作分离为可以单独或串联使用的离散组件。 ADO.NET包括用于连接数据库,执行命令和检索结果的.NET Framework数据提供程序。





更多关于:

ADO.NET概述 [ ^ ]

编写.NET Framework的通用代码... [ ^ ]

ADO。 NET示例应用程序 [ ^ ]



请阅读这些文章,然后再问一个问题(如果有的话)。


< BLO ckquote>



首先我想说的是,你需要的更好的方法是使用数据集(XSD)对象。

你可以添加一个抛出添加 - >新项目...然后选择数据集。

过去我像你现在那样做,但是更容易管理表格和它们的边界(datagrid,combobox等'')数据集。



其次,您要查找的代码是:

 SqlCommandBuilder b = new SqlCommandBuilder (_sdataadapter); 
_sdataadapter。更新(_ sdatatable);





之后做你需要的所有事情(添加,更新,删除)运行它,它会更新你的数据库。



通常最好单独进行这些操作它的工作原理很好,


hi! First of all I need know how Can ı do select delete and update operation on Datagrid shortcut.

I fill data like this

sql_cmd = sqLiteConnection1.CreateCommand();
            string CommandText = "Select * From PLU";
            DA = new SQLiteDataAdapter(CommandText, sqLiteConnection1);
            DS4.Reset();
            DA.Fill(DS4);
            DT = DS4.Tables[0];
            dataGridView4.DataSource = DT;
            sqLiteConnection1.Close();



DA:DataAdapter, DS4:DataSet, DT:DataTable

Can anybody help me?

解决方案

Your question is not well-formed and it''s hard to answer it...

Quote:

The DataGridView control[^] provides a powerful and flexible way to display data in a tabular format. You can use the DataGridView control to show read-only views of a small amount of data, or you can scale it to show editable views of very large sets of data.

You can extend the DataGridView control in a number of ways to build custom behaviors into your applications. For example, you can programmatically specify your own sorting algorithms, and you can create your own types of cells. You can easily customize the appearance of the DataGridView control by choosing among several properties. Many types of data stores can be used as a data source, or the DataGridView control can operate with no data source bound to it.


More about: DataGridView class[^]
DataEntry in the DatagridView control[^]

So, you can''t "select delete and update operation on Datagrid shortcut" - whatever it means.

To manipulate data, you need to use ADO.NET[^].

Quote:

ADO.NET separates data access from data manipulation into discrete components that can be used separately or in tandem. ADO.NET includes .NET Framework data providers for connecting to a database, executing commands, and retrieving results.



More about:
Overview of ADO.NET[^]
Writing Common Code for .NET Framework...[^]
ADO.NET Sample Application[^]

Please, read these articles, then ask a question again (if any).


Hi,

First I want to say that the better way to do what you need is with the dataset (XSD) object.
You can add one threw the add -> new item... and then chose dataset.
In the past I did it like you do now but it is much easier to manage the tables and their boundings (datagrid, combobox, etc'') with the dataset.

Second the code that you look for is this:

SqlCommandBuilder b = new SqlCommandBuilder(_sdataadapter);
_sdataadapter.Update(_sdatatable);



After you do all the things you need (add, update , delete) run this and it will update your data base.

usually it is preferred to do those operation separately it works fine together,


这篇关于DataGrid选择,删除和更新操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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