Pronto

Untitled

Sep 2nd, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Sub UpdateDatabase()
  2.         Dim deletedChildRecord As TrainCentreDataSet.CustomersDataTable = CType(TrainCentreDataSet.Customers.GetChanges(DataRowState.Deleted), TrainCentreDataSet.CustomersDataTable)
  3.         Dim addedChildRecord As TrainCentreDataSet.CustomersDataTable = CType(TrainCentreDataSet.Customers.GetChanges(DataRowState.Added), TrainCentreDataSet.CustomersDataTable)
  4.         Dim modifiedRecord As TrainCentreDataSet.CustomersDataTable = CType(TrainCentreDataSet.Customers.GetChanges(DataRowState.Modified), TrainCentreDataSet.CustomersDataTable)
  5.         Try
  6.             If deletedChildRecord IsNot Nothing Then
  7.                 CustomersTableAdapter.Update(deletedChildRecord)
  8.             End If
  9.             If addedChildRecord IsNot Nothing Then
  10.                 CustomersTableAdapter.Update(addedChildRecord)
  11.             End If
  12.             If modifiedRecord IsNot Nothing Then
  13.                 CustomersTableAdapter.Update(modifiedRecord)
  14.             End If
  15.             TrainCentreDataSet.AcceptChanges()
  16.         Catch ex As Exception
  17.             XtraMessageBox.Show("An Error Occured during the update process" & ex.Message)
  18.         Finally
  19.             If deletedChildRecord IsNot Nothing Then
  20.                 deletedChildRecord.Dispose()
  21.             End If
  22.             If addedChildRecord IsNot Nothing Then
  23.                 addedChildRecord.Dispose()
  24.             End If
  25.             If modifiedRecord IsNot Nothing Then
  26.                 modifiedRecord.Dispose()
  27.             End If
  28.             Me.CustomersTableAdapter.Fill(Me.TrainCentreDataSet.Customers)
  29.         End Try
  30.     End Sub
Add Comment
Please, Sign In to add comment