Re: Locking a record in Access from vb.net



There's no built-in support (at least, not that I'm aware of) for
pessimistic locking in ADO.NET. You could 'roll your own' locking mechanism.
Add a flag field to your table. Set it when a user selects that record for
editing, clear it when they save changes. Before selecting a record for
editing, check the flag. The drawback to that approach is that it will only
prevent 'locked' records from being edited by your app, or other apps that
are aware of and respect your custom locking mechanism. There's no way to
enforce it if other apps are unaware of or fail to respect your locking
mechanism. You'll also need to be very careful about releasing locks if a
user cancels an edit or if an error occurs.

A possible alternative might be to use 'classic' ADO, with pessimistic
locking, via COM interop. But that's just an 'off the top of my head' idea,
I haven't tested it.

BTW: There isn't any 'lockrecord' property in Access. Just thought I should
mention that so some poor unfortunate doesn't read this thread in the Google
newsgroup archives and spend half a day looking for it! :-)

--
Brendan Reynolds
Access MVP

"Roy" <Roy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:75424E43-7C69-4D8D-9E06-24C7AA26BDCC@xxxxxxxxxxxxxxxx
Hi all,

I need to lock a record while a user edits that record, so other users see
a
"Record is locked" message when try to access that specific record. I know
there is a lockrecord property in Access, but I'm not sure how to lock
this
record from my vb.net form.
Any help would be highly appreciated.

Roy



.



Relevant Pages

  • Interoperation of flock(2), fcntl(2), and lockf(3)
    ... Does that mean that each of those calls uses a locking mechanism ... error (it's a no-op case of upgrading the lock,) intermixing flock ...
    (freebsd-arch)
  • Interoperation of flock(2), fcntl(2), and lockf(3)
    ... Does that mean that each of those calls uses a locking mechanism ... error (it's a no-op case of upgrading the lock,) intermixing flock ...
    (freebsd-hackers)
  • Re[2]: SECURITY.NNOV: file locking and security (group policy DoS on Windows 2000 domain)
    ... I never intended to review all possible locking mechanism. ... to be open for writing, so, it's behind advisory (I'm talking about READ ... I don't use linux. ...
    (Bugtraq)
  • Re: Multiuser Problem
    ... Pessimistic locking - in todays modern languages this is not really the ... requires that you have a database transaction locking the row of the record ... Allow the user to edit the row but before you write the data back to ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Update Integrity
    ... you have imnplemented optimistic locking: ... AND RowVers = @RowVers ... Pessimistic locking isn't used much, mainly because neither option is very ...
    (microsoft.public.sqlserver.programming)