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
Project Description: This is an online customization printing system they use for multiple organizations to allow customizing  and access of materials they allocate to drive iss

What are resource files? The Resource files are the files which contain program resources. Many programmers think that resource files are used only for storing strings. But you

Design an interface and add code to command buttons using case statement, to find coursework to be calculated using formula 0.6*1/6*total Mark

I need Online Real Commission Management system Project Description: Real Estate -- Store and retrieve Purchase plot customers, Employee to refer the customers get commiss

What is DCOM? DCOM is different from COM in that it allows for creating objects distributed around  a network, and a protocol for invoking that object's methods, & secures the

What is three tier architecture? The 3 tier software architecture was comes into action in the 1990s to overcome the limitations of the 2 tier architecture. There are 3 laye

I need Simple upgrades for ASP.NET site I have an existing web solution, we need a new page for creating additional features. The current website is done in C#.NET and ASP.NET.

Define an array. An array is explained as a homogeneous collection of elements, stored at contiguous memory locations, which can be referred by the similar variable name. All t

What is an application object & how it is different from c ache object? The Application object can be used in many situations where we want the data to be shared across user

What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, like classes that contain properties, methods, fields, and events. An object is formed