ASP.NET, SQL Record Locking

  • Thread starter Thread starter John Walker
  • Start date Start date
J

John Walker

Hi.
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 asp.net 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.
Thanks!
John
 
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.
 
Back
Top