Re: Locking a record in Access from vb.net




I'm afraid I'm the wrong person to ask. My experience is mostly with DAO and
more recently with ADO.NET. I never did much work with 'classic' ADO.

--
Brendan Reynolds
Access MVP

"Roy" <Roy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3280D09F-9A02-49CE-9C9A-A5307BD70665@xxxxxxxxxxxxxxxx
Thanks Brendan,

Would you explain what object of classic ADO and how it should be
implemented?

Roy

"Brendan Reynolds" wrote:

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

  • Re: Monitoring Windows File Sharing
    ... if the OS is locking a larger 'chunk' of the file rather ... the server or just network access through file shares & UNC? ... The way many apps (e.g. ... > databases is to lock extents. ...
    (microsoft.public.windows.file_system)
  • Re: using clustered index to optimize inserts ...
    ... I will try to explain locking in terms of Sybase docs... ... Allpages Locking: Allpages locking locks both data pages and index ... the data page is locked with an exclusive lock. ... Clustered Index: The datarows will be arranged as per the clustered ...
    (comp.databases.sybase)
  • Re: CSingleLock - known behaviour?
    ... It is better to design code that doesn't require locking. ... If you don't need the resource, don't lock it. ... magnitude less efficient, than locking once. ...
    (microsoft.public.vc.mfc)
  • Re: Strange multi-user timing phenomenon
    ... table record with pessimistic locking and both edit the same record. ... the recordset will be sufficient to lock out other users. ... update the recordset (if you had to edit data) and then close it. ...
    (microsoft.public.access.formscoding)
  • Re: Strange multi-user timing phenomenon
    ... I tried your locking method using a perssimistic recordset and it appears to ... user places his lock and grabs the same record. ... I would try opening a fixed single-row recordset with pessimistic locking, ...
    (microsoft.public.access.formscoding)