Friday, 30 September 2011

How many ways are there to implement locking in ADO.NET?

Following are the ways to implement locking using ADO.NET:-
  • When we call “Update” method of Data Adapter it handles locking internally. If the Dataset values are not matching with current data in Database, it raises concurrency exception error. We can easily trap this error using Try. Catch block and raise appropriate error message to the user.
  • Define a Date time stamp field in the table. When actually you are firing the UPDATE SQL statements, compare the current timestamp with one existing in the database.
  • Check for original values stored in SQL SERVER and actual changed values. In stored procedure check before updating that the old data is same as the current data.

No comments:

Post a Comment