Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub UpdateDatabase()
- Dim deletedChildRecord As TrainCentreDataSet.CustomersDataTable = CType(TrainCentreDataSet.Customers.GetChanges(DataRowState.Deleted), TrainCentreDataSet.CustomersDataTable)
- Dim addedChildRecord As TrainCentreDataSet.CustomersDataTable = CType(TrainCentreDataSet.Customers.GetChanges(DataRowState.Added), TrainCentreDataSet.CustomersDataTable)
- Dim modifiedRecord As TrainCentreDataSet.CustomersDataTable = CType(TrainCentreDataSet.Customers.GetChanges(DataRowState.Modified), TrainCentreDataSet.CustomersDataTable)
- Try
- If deletedChildRecord IsNot Nothing Then
- CustomersTableAdapter.Update(deletedChildRecord)
- End If
- If addedChildRecord IsNot Nothing Then
- CustomersTableAdapter.Update(addedChildRecord)
- End If
- If modifiedRecord IsNot Nothing Then
- CustomersTableAdapter.Update(modifiedRecord)
- End If
- TrainCentreDataSet.AcceptChanges()
- Catch ex As Exception
- XtraMessageBox.Show("An Error Occured during the update process" & ex.Message)
- Finally
- If deletedChildRecord IsNot Nothing Then
- deletedChildRecord.Dispose()
- End If
- If addedChildRecord IsNot Nothing Then
- addedChildRecord.Dispose()
- End If
- If modifiedRecord IsNot Nothing Then
- modifiedRecord.Dispose()
- End If
- Me.CustomersTableAdapter.Fill(Me.TrainCentreDataSet.Customers)
- End Try
- End Sub
Add Comment
Please, Sign In to add comment