Guest User

Untitled

a guest
Aug 15th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. Dataset optimistic concurrency
  2. UPDATE Table1 Set Col1 = @NewCol1Value,
  3. Set Col2 = @NewCol2Value,
  4. Set Col3 = @NewCol3Value
  5. WHERE Col1 = @OldCol1Value AND
  6. Col2 = @OldCol2Value AND
  7. Col3 = @OldCol3Value
  8.  
  9. class OptLockDataSet {
  10. DataSet _data;
  11. DateTime LastUpdate {
  12. return _data.Tables["ChangeTracker"][0][0];//just for example :)
  13. }
  14. }
  15.  
  16. if(GetLastUpdateFromDB(_data) > LastUpdate ) {
  17. //This means that last update was changed because someone else
  18. //modified the data.
  19. //Show error to user and reload data from db.
  20. }
  21.  
  22. update data set @col1 = @val1 where last_update = @last_update
Add Comment
Please, Sign In to add comment