Updating Datagridview Values into Database

Updating Datagridview Values into Database

I am developing an forms application where user can get tables data from database into gridviewcontrol which is editable so that user can update some data in the grid and when user clicks update buttonon the form the updated datagrid values should update in database. User can update more column values at a time. I am working on datagrids for the frist time and I managed to get data from databse and display in data grid but I am not able to update edited data back top database.

2 Answers

If you are using a DataTable as a source to the DataGrid that shouldn't be so hard , you can get the changes in the DataTable using datatable.getchanges() // search for an example in getchanges()

and then update each row that has changed using the unique key ( i assume you have one ) of the row .

If you need to know how you update back to the database then you should check msdn for the exact method you have to use , depending of course on the one you used to load the data to the grid .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.