954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Modify data in Datagrid

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
[DG.DataSource=ds]
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.

basha_82
Newbie Poster
1 post since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

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.

williamrojas78
Junior Poster
111 posts since Jun 2005
Reputation Points: 23
Solved Threads: 10
 

I'm having the same problem.....what error messages are you getting?

SethR
Light Poster
33 posts since Oct 2005
Reputation Points: 10
Solved Threads: 1
 

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.
[code]

dataset2 = dataset1.getchanges
you then update the dataadapater
daadapter.update(dataset2)
[code]
I'm not sure about the syntax but u get the general idea.

Shum
Newbie Poster
5 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You