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
How can we implement singleton pattern in .NET ? The Singleton pattern basically focuses on having one and only one instance of the object running. Lets take an e.g. a windows

want to generate random numbers between 1-15 and no one should repeat until all numbers have come once....

Need to develop a simple .net software I am seeking someone who can design a customized software for me, prefrebly in .NET. I have a sql server backend which i would like to use

Define Network? A network is a set of devices linked by physical media links. A network is recursively is a connection of two or more nodes by a physical link or two or more

What is normalization & what are the types of normalization? Normalization is a set of rules that have been established to aid in the design of tables that are meant to be conn

Import Columns of Data into Data Table for Data Grid View in C# and WPF Need help with a project in C# / WPF. Trying to read a csv file or text file with columns of data that wi

Decision Making and Branching - C# Program Need Programming help on Decision Making and Branching in C#.

What does Address Of operator do? The Address Of operator generates a delegate object for the BackgroundProcess method. A delegate within VB.NET is a object-oriented, type-safe

What is the difference between OLEDB Provider and SqlClient? With respect to usage, there is no difference among OLEDB Provider and SqlClient. The dissimilarity lies in their p

What is an identifier? Identifiers are northing but names given to various entities uniquely identified in a program. The name of identifiers must vary in spelling or casing. F