[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to implement locking in ASP.NET application?

Posted on 2012-09-05
3
Medium Priority
?
755 Views
Last Modified: 2012-09-06
I've an ASP.NET application. Two users logged in simultaneously and in a Grid page both users choose same record. User1 modifies some data and click submit button. User2 modifies data and click submit button. At this time I would like to show a Pop-up message saying that Another User (ie User1) modified that data. Upon clicking Ok button I would like to rollback the User2's transaction. How to achieve this. Please guide me.

It would be great if I get any sample application or code. Thanks.
0
Comment
Question by:Easwaran Paramasivam
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
rajapandian_81 earned 2000 total points
ID: 38371175
Hi,

The easiest method is add one field "ModifiedDateTime" in database. When retrieving the record from database, get this field value also. Do your changes in grid. If other user has modified the record at this time, the retrieved value of "ModifiedDateTime" and database value of "ModifiedDateTime" will be different. So alert the user. If there is no datetime difference, update the record.
0
 
LVL 16

Author Closing Comment

by:Easwaran Paramasivam
ID: 38371189
Thanks.
0
 
LVL 12

Expert Comment

by:rajapandian_81
ID: 38371255
Welcome :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Screencast - Getting to Know the Pipeline
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question