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 would you implement inheritance using VB.NET? When we set out to execute a class using inheritance, we must first begin with an existing class from which we will derive our

wiConstellation WEB site Project Description: Creation of a dynamic corporate WEB site with administration panel, requirement collaboration, product definition, Q&A, user man

Explain keywords with example. Keywords are those words that are reserved to be used for an exact task. These words cannot be used as identifiers. You cannot use a keyword to

Print Floyd's Triangle - C# Program I am unable to make out how to print Floyd's Triangle in C# language. Can anyone suggest me any example for this.

Web Developer Project Description: We need of an expert web developer for long term association, please apply with models if you have the subsequent skills: ASP.NET MVC 3

How do I force the Dispose method to be called automatically, as clients can forget to call Dispose method? To Call the Dispose method in the Finalize method and in the Dispose

What is an interface and what is an abstract class? Please, expand by examples of using both. Explain why.   In a interface class, all methods are abstract without execut

Mention different types of data providers available in .NET Framework. .NET Framework Data Provider for SQL Server - Give access to Microsoft SQL Server 7.0 or later version. I

Assignment for inheritance based on c#

The Performance of the viewstate varies depending on the type of server control to which it is applied. The Text Box, Label,   RadioButton,CheckBox, and HyperLink are server contro