Ways to implement locking in ado.net, DOT NET Programming

What are the ways to implement locking in ADO.NET?

There are many ways to implement locking using ADO.NET which are shown below:-

1)Whenever we call "Update" method of DataAdapter it handles locking internally.

If the DataSet values are not matching with the current data in Database it raises concurrency exception error. We can easily find this error by using Try..Catch block and raise the appropriate error message to the user.

2)We can also define a Datetime stamp field in the table.When actually you are firing the UPDATE SQL statements compare the current timestamp with one existing in the database. The sample SQL below checks for the timestamp before updating and any mismatch in the timestamp  will not update the records. This is the best method used by industries for locking.

Update table1 set field1=@test where LastTimeStamp=@CurrentTimeStamp

3) We can also check for the original values stored in the SQL SERVER and actual changed values. In stored procedure check before updating that the old data is similar as the current. Fore Example shown below SQL before updating the  field1 we check that is the old field1 value same. If not then someone other has updated and necessary steps has to be taken.

Update table1 set field1=@test where field1 = @oldfield1value

Posted Date: 9/24/2012 5:10:16 AM | Location : United States







Related Discussions:- Ways to implement locking in ado.net, Assignment Help, Ask Question on Ways to implement locking in ado.net, Get Answer, Expert's Help, Ways to implement locking in ado.net Discussions

Write discussion on Ways to implement locking in ado.net
Your posts are moderated
Related Questions
What are the metrics followed in project management? The most metric sets deal with a variation of these attributes and are chosen to help the project managers gain insight int

Looking to build FIFA coins selling and buying website Project Description: I would like a website made for FIFA 14 TEAM. What this website will do is having automatically bu

Could you please explain to me the different types of DOT NET programming

how do you do dot net programming

Windows Phone 8 Player - Radio Live Streaming Native XAML and C# Project Description: Player for Windows Phone 8 Scope: The project evolves the development of app using

It's never told  to distribute complete implementation at client, due to following shown  reasons:- 1) Anyone can use ILDASM and decrypt your logic. 2) It is a bad architectu

What is XSLT? The XSLT is a rule based language used to transform XML documents into other file formats. The XSLT are nothing but generic transformation rules which can be appl

I want to prepare one web based application which have student registration and according to semester and every time it will change as per semester change according, now student ge

Required: An implementation of a two player game. Keep the game simple ROCK PAPER SCOSSORS A two player game, each player on a different browser instance.  (pro

can we use sql data base with visual studio