ASP.NET, SQL Record Locking


John Walker

Is there a convenient way to lock SQL records so that two users cannot
attempt to update the same row, thereby preventing users from overwriting
other user's data?
For example, we have a 2.0 application which allows a user to pull
up customer information, modify their information and save it back to the
database. if there is a different user attempting to pull up that same
customer record while the other user is viewing it in their browser we would
like to display a message "the customer record you are trying to access is
currently locked by another user."
We may also want to give each user a certain amount of time to have a record
locked before releasing it for access by other users.
Any advice would be appreciated.






As a followup, I now convert the timestamp/rowversion column to a bigint
when I pull it up to the webpage.

I've seen some other tricks, but that one works for me.

Select EmpID, convert(bigint, MyTimeStampColumn) as
MyTimeStampColumnAsBigInt, LastName, FirstName from dbo.Employee

something like that.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question