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
Question: (a) One of the advantages of the Session object is that it prompts to you when a user session begins. In this context, a user fills in a registration form and the Se


What are the steps to create a windows service in VB.NET ? The Windows Services are long-running executable applications that run in its own Windows session, which then has the

Manifest Assembly metadata is always stored in the Manifest. Manifest consists of all metadata required to do the following things: 1) Version of assembly 2) Security ident

I need Windows Phone App (WP 8 and above) I am seeking an app developer/designer to develop me a Windows Phone app. This will be an app where users will post questions in the

Determining salvage value of an item - C# Program I am a learner of C# language and i am struggling with the programming functions in c#. Can you have any code examples for th

ASP Developer- We are needed to hire an ASP developer for some urgent work. He needs to add a new page to an already prepared site; the page is already completed in HTML. He jus

Work on different coding using visual studio 2012/2013 writing Java script as well as C# codes. Project Description: I want to shift to new Programming Env. and I would like

Project Description: Section - Mobile Data Collection System Using the Microsoft Mobile .Net Framework or .Net Compact Framework and ASP.NET web technology develop a mobile d

What is RAID and how does it work? The Redundant Array of Independent Disks (RAID) is a term used for describing the technique of improving data availability through the use of