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 do we access view state value of the page in the next page? The View state is page specific; it contains information about controls embedded at the particular page. ASP.NET

What is the difference between Class and structure's? The main differences between them are as follows:- 1) The Structure is value types while classes are referen

Regular IT Support Work Project Description: I have a number of clients in the UK that I give you IT support for on their Windows desktops and servers and linked peripherals

What are the different types of replication supported by SQL SERVER? There are 3  types of replication supported by SQL SERVER which are shown below:- 1) Snapshot Replicati

Give a brief introduction on side-by-side execution. Can two applications, one using private assembly and the other using the shared assembly be stated as side-by-side executables?

TFS - SpiraTeam synchronization plugin. Project Description: We would like you to develop the subsequent requirements in one plug-in already in production. The plug-in was de

WP7 get data from public API with XML or JSON Project Description: Hello, I'm seeking someone who knows his way around using an API with XML or JSON output in a windows phone

Explain why your project needed XML. Remember XML was meant to exchange data between the two entities as you can define your user friendly tags with ease. In the real world sce

What is XPath? XPath stands for XML Path. It is a language used to access dissimilar parts of an XML document, such as elements and attributes.

What are the problems that can occur if you do not implement locking properly in SQL SERVER? The problems that occur if you do not implement locking properly in SQL SERVER is a