Click to See Complete Forum and Search --> : Hi! Is there anyone out there how can tell me how record lockting with DAO works. REWARD: 1 beer ca


Marc Lisketing
May 13th, 1999, 01:47 PM
Hi everyone!

When I use the Edit()-Methode to lock a recordset in a pessimistic-opened CDaoRecordset, the Edit()-Methode seemed to look more than
one record! Does anybody know, why the Edit()-Method looks more than the current record? I would be nice I anyone will reply immediately
because I will have to install this programm on Monday!

DB.Open("d:\\projekte\\dblock\\dblock.mdb", FALSE, FALSE);

pOrder = new CDaoRecordset(&DB);

pOrder->Open(dbOpenDynaset, "select * from order order by order_nr", dbSeeChanges);

pOrder->SetLockingMode(TRUE);

pOrder->MoveLast();

// Lock the current record! (or more?!)
try {
pOrder->Edit();
}

catch (CDaoException* e) {

if(e->m_pErrorInfo->m_lErrorCode == 3260) {

//...record is locked!
}
}

When I start two applications on my system this works fine. The second application recognize that the last record is locked.
But when I scroll forword in the second application, the previous 4 or 5 records are locked too. But there wqs only
the last record locked by the first application! I tried to turn off the DAO-record caching by the following statements:

pOrder->SetCacheSize(0);
pOrder->SetCacheSize(0);
pOrder.>FillCache();

But this didnīt work too.

Iīm looking forward to any ideas, suggestions or what ever!

Thanks!

Marc

Shahzad
May 13th, 1999, 10:35 PM
I could not get, what do you mean by 'locking' a record. I have used Edit to change the current recordset but i am sorry, could not get your problem.

Pit Gal
May 14th, 1999, 01:48 AM
DAO Lock Pages not only Single Records.

Marc Lisketing
May 14th, 1999, 01:59 AM
Hi Shahzad!

With the locking of a record I mean that a record is exclusively locked for exactly ONE application
at one time in a multiuser/network environment.for editing. If I would use no record locking this
will produce different site effects, e.g. three applications witch are running at the same time, edit
for example the description of a part at the same time. What will be the right part description?

With record locking you can avoid such situations. My problem is, that the Edit()-Methode locks
more than the current record. The Edit()-Methode locks 3 or 4 records before and behind the
current record too! And so this means, that the other running applications on the network can
not edit these records. For the current record this is what I want but not for the others.

So the questions is: Why does the Edit-Methode() locks more than the current record?

When you have any ideas i am looking forward to them - and donīt forget the reward :-) !

Best regards,

Marc

Daren Chandisingh
May 14th, 1999, 06:51 AM
Whether locking is pessimistic or not, DAO locks the 2Kb page that contains your record. Pessimistic locking only determines when the locking occurs (on Edit() if pessimistic, else on Update()).

If a particular page is locked, no other user can edit any records in that page, even if they are not the same record as the one being edited.



--
Daren Chandisingh