Private Function CreateMessage(ByVal cr As NorthwindDataSet.CustomersRow) As String
Return _
"Database: " & GetRowData(GetCurrentRowInDB(cr), Data.DataRowVersion.Default) & vbCrLf & _
"Original: " & GetRowData(cr, Data.DataRowVersion.Original) & vbCrLf & _
"Proposed: " & GetRowData(cr, Data.DataRowVersion.Current) & vbCrLf & _
"Do you still want to update the database with the proposed value?"
End Function
Private TempCustomersDataTable As New NorthwindDataSet.CustomersDataTable
Private Function GetCurrentRowInDB(ByVal RowWithError As NorthwindDataSet.CustomersRow) As NorthwindDataSet.CustomersRow
Dim currentRowInDb As NorthwindDataSet.CustomersRow
Me.CustomersTableAdapter.Fill(TempCustomersDataTable)
currentRowInDb = TempCustomersDataTable.FindByCustomerID(RowWithError.CustomerID)
Return currentRowInDb
End Function
' This method takes a CustomersRow and RowVersion and returns
' a string of column values to display to the user.
Private Function GetRowData(ByVal custRow As NorthwindDataSet.CustomersRow, ByVal RowVersion As Data.DataRowVersion) As String
Dim rowData As String = ""
For i As Integer = 0 To custRow.ItemArray.Length - 1
rowData += custRow.Item(i, RowVersion).ToString & " "
Next
Return rowData
End Function
Private Sub ProcessDialogResult(ByVal response As Windows.Forms.DialogResult)
Select Case response
Case Is = Windows.Forms.DialogResult.Yes
NorthwindDataSet.Customers.Merge(TempCustomersDataTable, True)
UpdateDatabase()
Case Windows.Forms.DialogResult.No
NorthwindDataSet.Customers.Merge(TempCustomersDataTable)
MsgBox("Update cancelled")
End Select
End Sub