Force update of db after concurrency violation

  • Thread starter Thread starter Rob Oldfield
  • Start date Start date
R

Rob Oldfield

Hi,

I'm coping with concurrency errors as detailed in
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconoptimisticconcurrency.asp but I have a situation where, in a
particular situation, I want to force the update command to _always_ write
data back to my database.

I'd assumed that, in the code...

Private Shared Sub OnRowUpdated(sender As object, args As
SqlRowUpdatedEventArgs)
If args.RecordsAffected = 0
args.Row.RowError = "Optimistic Concurrency Violation Encountered"
args.Status = UpdateStatus.SkipCurrentRow
End If
End Sub

....that changing this to....

args.Status = UpdateStatus.Continue

would do this, but I'm getting the same result whichever method I use. Am I
missing something obvious, or should I just be creating the SQL for the
update command and just running that command directly?

Thanks.
 
Hi Rob,

Rob Oldfield said:
Hi,

I'm coping with concurrency errors as detailed in
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconoptimisticconcurrency.asp but I have a situation where, in a
particular situation, I want to force the update command to _always_ write
data back to my database.

...that changing this to....

args.Status = UpdateStatus.Continue

would do this, but I'm getting the same result whichever method I use. Am I
missing something obvious, or should I just be creating the SQL for the
update command and just running that command directly?

Yup, exactly - and then set args.Status to Continue if you want to suppres
error notification.
 
Back
Top