Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want save the data of the datagridview with a button. But I should change line in the grid before saving to put the data in the database. What I want is save the data of the current line without changing the line.

VB
                   daAdapter = New OleDb.OleDbDataAdapter("Select * from COMPAGNIES order by NOM_COMPAGNIE " & Trie, dbcn)
                   daAdapter.Fill(dtTransac)
                   dvTransac = New DataView(dtTransac)

dgvEdit.DataSource = dvTransac

VB
Public Overrides Function FormSauve() As Boolean
                Dim cmdbuilder As New OleDb.OleDbCommandBuilder(daAdapter)
                daAdapter.Update(dtTransac)
End sub


...
Sorry I think I didn’t explain my problem correctly. Currently, if I change any data in the grid without changing lines, the data will not be saved in the DB when I call the FormSauve sub. I should change the line in the grid and call the FormSauve sub to save the data in the DB.

What I want is to be able to save the data in the DB in the FormSauve sub without having to change the line.

Thanks,
Posted
Updated 9-Jan-12 8:04am
v2

you need to get the dirty data of the cells, and this use to update the data.
also you can use the cellvalidating event or similar to get the formatted data of the e element like this:

private sub datagridview1_cellvalidating(byval e as......)

in this event you can get the data with this:

e.formattedvalue

at this moment you can get the data.

and then, you can retrieve the data to other dataset or something and updata to db.


i hope you this is useful to you.

regards.
 
Share this answer
 
v2
Comments
Brutt 9-Jan-12 11:04am    
Sorry I think I didn’t explain my problem correctly. Currently, if I change any data in the grid without changing lines, the data will not be saved in the DB when I call the FormSauve sub. I should change the line in the grid and call the FormSauve sub to save the data in the DB.

What I want is to be able to save the data in the DB in the FormSauve sub without having to change the line.

Thanks,
you must tell at the component that you have binding the dataview to update the binding.
In case you haved use the Infragistics grid you can use the grid.activerow.update command.
 
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