I'm trying to make a bulk update in the database using DataAdapter.Update
, and the user has the option to cancel the operation.
Question: How to stop the update operation when the user clicks the cancel button?
My Code::
Log("@@@@@ Saving BMPImages paths to the database @@@@@")
objCommandBuilder = New SqlCommandBuilder(daImages)
SavingImageObj.MyProgressBar.Maximum = tblImages.GetChanges.Rows.Count
AddHandler tblImages.RowChanged, New DataRowChangeEventHandler(AddressOf tblImages_changed)
daImages.Update(dsMAP, "BMPImages")
And this is the RowChanged Handler::
Private Sub tblImages_changed(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs)
'Increment progress bar
SavingImageObj.ThreadTask()
If SkipFraming = True Then
' Here I should do something to stop the daImages.Update
' from continuing to execute
End If
End Sub
I'm setting a flag [SkipFraming] indicating that i should stop the operation when the cancel button is clicked.