"David C. Barber" <da***@NOSPAMdbarber.com> wrote in message
news:4e********************@comcast.com...
I'm trying to determine which user has locked a given record from VB6.
I know I can use sp_lock and sp_who, and match up the data to determine
which users have locked records in my database, however I haven't seen a
way
to match the specific user to the specific record. What am I missing
here?
Thanks!
*David*
Further to the good answers you already have.
Should you find that pessimistic locking is a real must for some reason.
There's another approach to consider.
This is called soft locking.
It ain't really a lock in database terms at all.
With this you have one or two extra columns appended to each table.
User (optional ) and datetime.
When the user wants to mark data as locked, you lock, read, update the user
and datetime stamp.
When the changes are applied back or the user wants to free up the record,
the user is blanked and the datetime set to null.
The datetime is there so you can check to see if anyone's gone and left
their data locked for some inordinate amount of time.
This approach can be handy for those sort of apps where someone wants to
copy some data to a laptop, go off on a site visit or somesuch, update the
data on their laptop at clients or in transit and then eventually write it
all back when they're next in the office.
The downsides of softlocking are that you write updates to lock and unlock;
you can end up with everyone leaving locks all over the show if you're not
careful and your users don't match up to expectations.
Often, pessimistic is suffiicient.
--
Regards,
Andy O'Neill