Hi i am basha,
i am new to VB.NET.
I have a problem, i am able to retrieve data in datagrid throug dataset.
code is
but if i change any data in grid, it's not changing in database.
please tell me why its not changing and tell me the solution to change data in database using datagrid.

10 Years
Discussion Span
Last Post by Shum

Hi Basha

To change the data in the database itself you have to first see if the dataset has changes and then update the database. The changes you make to the datagrid will be reflected in the dataset, but if you close the form without updating the dataset you will lose the changes.

You can create a commandbuilder which will create the commands to update the database for you, and you have to use the same dadaAdapter you used to fill the dataset.

Hope it helps.


You need to use the getchanges method of dataset and pass it to a new dataset then set the new dataset to be the old one then update the dataadapter.
dataset1 is the original dataset.
dataset2 is the one which contains changes.

dataset2 = dataset1.getchanges

you then update the dataadapater


I'm not sure about the syntax but u get the general idea.

Edited by Dani: Formatting fixed

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.