Click here to Skip to main content
15,896,466 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
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.
Posted

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900