[2005] Saving the changes made to a datagridview.
Hello,
I have a datagridview which I fill with data using a bindingsource. I am using typed datasets and have set the properties of the bindingsource to the typed dataset and data table using the designer. I can then use the table adapter to fill the dataset and assign the data source of the datagridview to the bindingsource. This works fine. My code shows below.
However, I am not sure about the code that will allow me to edit the datagridview and then save all the changes. The user will enter or edit some of the values in the grid. Once they have finished they will click a button to save all changes to the database.
Does anyone have any code samples of this?
Many thanks for any advice,
Code:
'Fill the software part
Private Sub FillSoftware()
Try
Me.TA_Software_dsComponent_Equipment.Fill(Me.DsAddComponetAndEquipment.Software)
Me.dgvSoftware.DataSource = Me.bsSoftware
Me.HideSoftwareColumns()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Re: [2005] Saving the changes made to a datagridview.
Something like this straight from MSDN:
vb.net Code:
Try
Me.Validate()
Me.CustomersBindingSource.EndEdit()
Me.CustomersTableAdapter.Update(Me.NorthwindDataSet.Customers)
MsgBox("Update successful")
Catch ex As Exception
MsgBox("Update failed")
End Try
More detail here. Good luck!