Showing posts with label locking. Show all posts
Showing posts with label locking. Show all posts

Friday, March 30, 2012

how can i reserve a record to prevent anyone else from editing for X minutes?

Hey All,

I think this is something like locking, but not quite. I need to select a record in a database and display the information to the end user. The end user has a few minutes to review it before giving the ok at which point I will update the record.

However, while the user is reviewing the record, i dont want anyone else to be able to grab that record. I also want to make sure that if the user doesnt submit the page, that the record will be freed up and not indefinitely marked as taken.

What would be the best way to do this? This is with .net 2.0 and sql2000

I am afraid you want to prevent the following problem:

User A retrieves a record and it takes a long time before he submit and during that time User B updated that record so when user submit he will overwrite the record.

You can solve this problem by using the following way:

When a user submits a record you check the database to see if it has been updated by other users if so stop updating, display the updated record and ask him to try again.

Hope it helps.

|||

Thats not really an ideal solution since it means the user may fill out all their info, hit submit and then find out everything they submitted is now invalid.

However, i got some advice from the aspadvice.com ,mailing lists which seem like a good idea. I can add a date field to the table called LastLocked - and when i do my select, i only grab records where the lock is older then X minutes. I can also add a field LockedBy so that the user can access their own locked records. I think this will work for me.


thanks

Monday, March 12, 2012

how can i know which user is locking a table

how can i know which user is locking a tablesp_who2
Roji. P. Thomas
Net Asset Management
http://toponewithties.blogspot.com
"Win" <aaa@.aaa.com> wrote in message
news:uKxIs4vpFHA.3552@.TK2MSFTNGP10.phx.gbl...
>
>|||It just show the database
I want to know which table
"Roji. P. Thomas" <thomasroji@.gmail.com> wrote in message
news:#UQ836vpFHA.2472@.tk2msftngp13.phx.gbl...
> sp_who2
> --
> Roji. P. Thomas
> Net Asset Management
> http://toponewithties.blogspot.com
>
> "Win" <aaa@.aaa.com> wrote in message
> news:uKxIs4vpFHA.3552@.TK2MSFTNGP10.phx.gbl...
>|||and then using sp_locks <spid> you could see what objects are locked.
select object_id()
"Roji. P. Thomas" wrote:

> sp_who2
> --
> Roji. P. Thomas
> Net Asset Management
> http://toponewithties.blogspot.com
>
> "Win" <aaa@.aaa.com> wrote in message
> news:uKxIs4vpFHA.3552@.TK2MSFTNGP10.phx.gbl...
>
>|||Look for the spid column in the results of the both
sp_lock and sp_who2.
Roji. P. Thomas
Net Asset Management
http://toponewithties.blogspot.com
"Win" <aaa@.aaa.com> wrote in message
news:%23KuGJ9vpFHA.2156@.TK2MSFTNGP14.phx.gbl...
> It just show the database
> I want to know which table
> "Roji. P. Thomas" <thomasroji@.gmail.com> wrote in message
> news:#UQ836vpFHA.2472@.tk2msftngp13.phx.gbl...
>