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
Your first assignment will require you to develop a record processing system in both ASP and PHP, giving you an opportunity to see two modern web scripting languages in action.

Ask queyuyuystion #Minimum 100 words accepted#

1. What are the limitations of file based data storing techniques?

What is .NET Framework? .NET Framework is a complete environment that permits developers to develop, run, and deploy the following applications:     Windows services

What are major difference between classic ADO and ADO.NET ? Some major differences between the classic ADO & ADO.NET are as follows: 1) As in the classic ADO we had server a

A fresh web project utilizing ASP.NET 4.5, MVC 5 with Visual Studio 2013 a) Excellent web layout DESIGN skills using CSS. b) Solid experience with ASP.NET 4.0 MVC 4. c) Cu

Print Triangle in Reverse Pattern - C# Program Need the code of C# Program for Print Triangle in Reverse Pattern.

MVC -C# Single Page Application Project Description: Construct a site similar to prototype: To explain briefly: 1) Single Page Application 2) Loginig funcionality

What precautions we need to take while deploying satellite assemblies? When we distribute the assembly, the folder structure has to be very organized. The table below shows how

Experienced Microsoft .NET web developer The developer must be reliable as well as most of all use best practices for coding as well as application design. a) .NET 3.5 (ideal