hi
I am new in .net so please help me i stucked,I have a datagridview and i made some changes to it after that whenever i clicked on the update button the datagridview data should be updated in the database so that next when i want to get the values from the database the modified data will come.
Thanks.
解决方案For this purpose the following procedure can be adopted.
In ADO.NET we can work in disconnected model. i.e. The data from the database is read into the DataSet in the program, required modification are done to the data in the DataSet and then the data is written back to the database.
Create a DataSet. Typed DataSet is easy to create using the AddNewDataSource wizard. A tutorial is given here
http://www.mini.pw.edu.pl/~mossakow/materials/presentations/adonet.3.5/typed_datasets/index.html[^]
Then the data is read to be read into the dataset, using TabeAdapters of the corresponding DataTables.
The DataTable are bound to the DataGridView, to show and modify the data.
Then the modified data is to be saved to the database.
A general purpose class to read and save the data is given in this Code Project article.
General purpose class to fill DataTable(s) from DataBase and to save DataTable(s) to DataBase using reflection[^]]
I think this may be helpful to you.
本文介绍如何在ADO.NET中使用DataSet操作DataGridView,实现数据读取、修改并在数据库中更新的完整流程。通过创建TypedDataSet,绑定到DataGridView,然后使用TableAdapter进行数据交互,确保数据一致性。适合初学者理解数据管理基本步骤。

2374

被折叠的 条评论
为什么被折叠?



