Board index » delphi » ADO-Access2000-Multiuser-Edit Locking?

ADO-Access2000-Multiuser-Edit Locking?

When a user is editing a record other users should not be able to edit until
the edit is cancelled or the record is posted.

I would like to give a message that ' This Record Is Currently In Use'

How can I do This?

Regards

John

 

Re:ADO-Access2000-Multiuser-Edit Locking?


An easier way to handle inserts, edits, deletes is to NOT lock a dataset by
putting the dataset in edit mode.
Use SQL statements to handle inserts, updates, and deletes and treat all DB
manipulations as transactions.

For Ex:
 {--- call begintrans() ---}
INSERT INTO tbl_employees
(emp_fname, emplname, emp_phone_ext)
 VALUES
("John", "Doe", "2316");
{--- call commit() ---}

Putting a dataset in edit mode can theoretically block ALL other users from
using the database.
Consider a user starts an edit and then walks away from the PC to go to
lunch...

HTH

Quote
"john" <jflu...@webdatabases.co.uk> wrote in message

news:3bdad54b_1@dnews...
Quote
> When a user is editing a record other users should not be able to edit
until
> the edit is cancelled or the record is posted.

> I would like to give a message that ' This Record Is Currently In Use'

> How can I do This?

> Regards

> John

Re:ADO-Access2000-Multiuser-Edit Locking?


The other side to the coin is that a user fills out a ten page document only
to find that upon post the record has been changed by another user and all
the typing is lost. In this case I need to stop it at source.

Any Ideas? I've been trawling the newsgroups and can't find a way to say
this record is currently in use come back later.

Regards

John

Quote
"jqpdev" <jqp...@whowhatwhere.com> wrote in message

news:3bdb482f$1_2@dnews...
Quote
> An easier way to handle inserts, edits, deletes is to NOT lock a dataset
by
> putting the dataset in edit mode.
> Use SQL statements to handle inserts, updates, and deletes and treat all
DB
> manipulations as transactions.

> For Ex:
>  {--- call begintrans() ---}
> INSERT INTO tbl_employees
> (emp_fname, emplname, emp_phone_ext)
>  VALUES
> ("John", "Doe", "2316");
> {--- call commit() ---}

> Putting a dataset in edit mode can theoretically block ALL other users
from
> using the database.
> Consider a user starts an edit and then walks away from the PC to go to
> lunch...

> HTH

> "john" <jflu...@webdatabases.co.uk> wrote in message
> news:3bdad54b_1@dnews...
> > When a user is editing a record other users should not be able to edit
> until
> > the edit is cancelled or the record is posted.

> > I would like to give a message that ' This Record Is Currently In Use'

> > How can I do This?

> > Regards

> > John

Re:ADO-Access2000-Multiuser-Edit Locking?


Quote
"john" <jflu...@webdatabases.co.uk> wrote in message

news:3bdbc375_1@dnews...
| The other side to the coin is that a user fills out a ten page document
only
| to find that upon post the record has been changed by another user and all
| the typing is lost. In this case I need to stop it at source.
|
| Any Ideas? I've been trawling the newsgroups and can't find a way to say
| this record is currently in use come back later.

Set a flag in the record.

--

Quidquid latine dictum sit, altum viditur.
#319

Re:ADO-Access2000-Multiuser-Edit Locking?


Yes

And what when the system goes down before you unset it?

Quote
"DRS" <d...@removethis.ihug.com.au> wrote in message news:3bdc0049_2@dnews...
> "john" <jflu...@webdatabases.co.uk> wrote in message
> news:3bdbc375_1@dnews...
> | The other side to the coin is that a user fills out a ten page document
> only
> | to find that upon post the record has been changed by another user and
all
> | the typing is lost. In this case I need to stop it at source.
> |
> | Any Ideas? I've been trawling the newsgroups and can't find a way to say
> | this record is currently in use come back later.

> Set a flag in the record.

> --

> Quidquid latine dictum sit, altum viditur.
> #319

Re:ADO-Access2000-Multiuser-Edit Locking?


Quote
> The other side to the coin is that a user fills out a ten page document only
> to find that upon post the record has been changed by another user and all
> the typing is lost.

No typing lost in this case (an update conflict). Instead you are notified by
ADO about the conflict and you are given the freedom to decide how to handle
it. You loose the typing only if you choose to.

--
Vassil Nazarov
http://web.orbitel.bg/vassil/

Re:ADO-Access2000-Multiuser-Edit Locking?


Quote
"Vassil Nazarov" <vas...@mail.orbitel.bg> wrote in message

news:3bdc8bdb_1@dnews...
| > The other side to the coin is that a user fills out a ten page document
only
| > to find that upon post the record has been changed by another user and
all
| > the typing is lost.
|
| No typing lost in this case (an update conflict). Instead you are notified
by
| ADO about the conflict and you are given the freedom to decide how to
handle
| it. You loose the typing only if you choose to.

To do it properly you need to set the recordset's Filter property to
adFilterConflictingRecords and see if the RecordCount is > 0.  You can then
cycle through the result, checking each record's Status property for values
of adRecNew (the record contains a pending insert, possible after a failed
update), adRecModified (the record contains a pending modification, possible
after a failed update), or adRecConcurrencyViolation (the record contains a
pending change because the update attempt failed as a result of an
optimistic updating conflict).

If you set the Update Resync dynamic property in the Recordset's Properties
collection to adResyncConflicts, the ADO Cursor Engine will automatically
retrieve the current contents of the record you're attempting to update if a
conflict occurs.  You can also call the Resync method on the Recordset
object to retrieve this data on a record with pending changes.  This method
will retrieve data for only the records in your Recordset that contain
pending changes and that satisfy the criteria of the value used in the
AffectRecords parameter.

When you use the Update Resync property on the Recordset object, the current
contents of that record in the database are placed in the UnderlyingValue
property of the Field object.  The local changes are stored in the Value
property of the Field object and that the data initially retrieved from the
database is stored in the OriginalValue property.

If you want to use the Resync method rather than the Update Resync property,
you'll need to set the ResyncValues parameter on the method to
adResyncUnderlyingValues, in order to store the current contents of the
record into the UnderlyingValue property on each Field object.  Keep in mind
that you can use the Resync method to retrieve data this way only on a
Recordset object that uses batch optimistic locking.  If your Recordset
object uses simple optimistic locking, the Resync method will generate an
error if the record contains a pending change.  The Update Resync property
does not enforce such a restriction.

--

Quidquid latine dictum sit, altum viditur.
#319

Re:ADO-Access2000-Multiuser-Edit Locking?


Quote
"john" <jflu...@webdatabases.co.uk> wrote in message

news:3bdc7bc5$1_1@dnews...
Quote
| "DRS" <d...@removethis.ihug.com.au> wrote in message

news:3bdc0049_2@dnews...
| > "john" <jflu...@webdatabases.co.uk> wrote in message
| > news:3bdbc375_1@dnews...
| > | The other side to the coin is that a user fills out a ten page
document
| > only
| > | to find that upon post the record has been changed by another user and
| all
| > | the typing is lost. In this case I need to stop it at source.
| > |
| > | Any Ideas? I've been trawling the newsgroups and can't find a way to
say
| > | this record is currently in use come back later.
| >
| > Set a flag in the record.

| Yes
|
| And what when the system goes down before you unset it?

Timestamp the flag.  Reset all flags upon a system restart.

--

Quidquid latine dictum sit, altum viditur.
#319

Re:ADO-Access2000-Multiuser-Edit Locking?


Are all these filter properties on a standard dataset as I can't find them?
D5.

Quote
"DRS" <d...@removethis.ihug.com.au> wrote in message news:3bddca37_2@dnews...
> "Vassil Nazarov" <vas...@mail.orbitel.bg> wrote in message
> news:3bdc8bdb_1@dnews...
> | > The other side to the coin is that a user fills out a ten page
document
> only
> | > to find that upon post the record has been changed by another user and
> all
> | > the typing is lost.
> |
> | No typing lost in this case (an update conflict). Instead you are
notified
> by
> | ADO about the conflict and you are given the freedom to decide how to
> handle
> | it. You loose the typing only if you choose to.

> To do it properly you need to set the recordset's Filter property to
> adFilterConflictingRecords and see if the RecordCount is > 0.  You can
then
> cycle through the result, checking each record's Status property for
values
> of adRecNew (the record contains a pending insert, possible after a failed
> update), adRecModified (the record contains a pending modification,
possible
> after a failed update), or adRecConcurrencyViolation (the record contains
a
> pending change because the update attempt failed as a result of an
> optimistic updating conflict).

> If you set the Update Resync dynamic property in the Recordset's
Properties
> collection to adResyncConflicts, the ADO Cursor Engine will automatically
> retrieve the current contents of the record you're attempting to update if
a
> conflict occurs.  You can also call the Resync method on the Recordset
> object to retrieve this data on a record with pending changes.  This
method
> will retrieve data for only the records in your Recordset that contain
> pending changes and that satisfy the criteria of the value used in the
> AffectRecords parameter.

> When you use the Update Resync property on the Recordset object, the
current
> contents of that record in the database are placed in the UnderlyingValue
> property of the Field object.  The local changes are stored in the Value
> property of the Field object and that the data initially retrieved from
the
> database is stored in the OriginalValue property.

> If you want to use the Resync method rather than the Update Resync
property,
> you'll need to set the ResyncValues parameter on the method to
> adResyncUnderlyingValues, in order to store the current contents of the
> record into the UnderlyingValue property on each Field object.  Keep in
mind
> that you can use the Resync method to retrieve data this way only on a
> Recordset object that uses batch optimistic locking.  If your Recordset
> object uses simple optimistic locking, the Resync method will generate an
> error if the record contains a pending change.  The Update Resync property
> does not enforce such a restriction.

> --

> Quidquid latine dictum sit, altum viditur.
> #319

Re:ADO-Access2000-Multiuser-Edit Locking?


Quote
"john" <jflu...@webdatabases.co.uk> wrote in message

news:3be04c6e_1@dnews...
| Are all these filter properties on a standard dataset as I can't find
them?
| D5.

Reread what I wrote.  You apply the settings to the *recordset*, ie:

uses
  ADOdb, ADOInt;

ADODataset1.Recordset.Filter := adFilterConflictingRecords;

--

Quidquid latine dictum sit, altum viditur.
#319

Re:ADO-Access2000-Multiuser-Edit Locking?


Thanks for that. Really appreciate it. Just got to sit down and work out how
to put it all together using  tips from your emails. AdoInt allowed me to
compile. Before you mentioned it I never new it existed I'm new to working
with ADO and am more of a component user than a builder.

Regards

John

Quote
"DRS" <d...@removethis.ihug.com.au> wrote in message news:3be053e8_1@dnews...
> "john" <jflu...@webdatabases.co.uk> wrote in message
> news:3be04c6e_1@dnews...
> | Are all these filter properties on a standard dataset as I can't find
> them?
> | D5.

> Reread what I wrote.  You apply the settings to the *recordset*, ie:

> uses
>   ADOdb, ADOInt;

> ADODataset1.Recordset.Filter := adFilterConflictingRecords;

> --

> Quidquid latine dictum sit, altum viditur.
> #319

Re:ADO-Access2000-Multiuser-Edit Locking?


Quote
"john" <jflu...@webdatabases.co.uk> wrote in message

news:3be101a1_2@dnews...
| Thanks for that. Really appreciate it. Just got to sit down and work out
how
| to put it all together using  tips from your emails. AdoInt allowed me to
| compile. Before you mentioned it I never new it existed I'm new to working
| with ADO and am more of a component user than a builder.

No worries.  If you have a problem compiling because you're trying to use a
constant like adFilterConflictingRecords then just use Delphi's Find In
Files option.

--

Quidquid latine dictum sit, altum viditur.
#319

Other Threads