The definition of my table is quiet easy:
Id - Int - 4 - Null NOT allowed
Desc1 - Varchar - 100 - Null Allowed
Desc2 - Varchar - 100 - Null Allowed
And here is the code:
1) Update command:
Private Sub cmdUpd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpd.Click
Dim con As New ds_vehicle
Me.BindingContext(loc_ds_vehicle, "cat_veh").EndCurrentEdit()
ds = CType(loc_ds_vehicle.GetChanges, CSF.ds_vehicle)
con.UpdateDataSource(ds)
loc_ds_vehicle.Merge(ds)
loc_ds_vehicle.AcceptChanges()
End Sub
2) DataAdapter Update defined in another module:
Public Sub UpdateDataSource(ByVal ds As CSF.ds_vehicle)
DbConnection.Open()
Dim UpdatedRows As System.Data.DataSet
Dim InsertedRows As System.Data.DataSet
Dim DeletedRows As System.Data.DataSet
UpdatedRows = ds.GetChanges(System.Data.DataRowState.Modified)
InsertedRows = ds.GetChanges(System.Data.DataRowState.Added)
DeletedRows = ds.GetChanges(System.Data.DataRowState.Deleted)
Try
da_vehicle.Update(UpdatedRows)
da_vehicle.Update(InsertedRows)
da_vehicle.Update(DeletedRows)
Catch updateException As System.Exception
MsgBox("Caught exception: " & updateException.Message)
End Try
Me.DbConnection.Close()
End Sub