Pessimistic start locking at which line ?

  • Thread starter Thread starter S.L.
  • Start date Start date
S

S.L.

Hi, I'm testing locking in MS Access XP with ADO 2.7. My testing code is
below :

Set cnn = CurrentProject.Connection
rst.Open "select * from MTR1 where MTR1_CD = 'A' ", cnn, adOpenKeyset,
adLockPessimistic
Do While True
rst!MTR1_No = rst!MTR1_No + 1 ' <------ Line 1
rst.Update ' <----- Line 2
rst.Close : set rst = Nothing
Loop

I found that when I create 2 forms with the same code and run both, Error
about locking is detected on Line 2. By use Pessimistic locking, Should it
start locking on Line 1 and Should locking error (from second form) is
detected on Line 1 also, shoundn't it ? Otherwise, It's nothing different
from Optimistic locking.

TIA
 
S> Hi, I'm testing locking in MS Access XP with ADO
S> 2.7. My testing code is below :

S> Set cnn = CurrentProject.Connection
S> rst.Open "select * from MTR1 where MTR1_CD = 'A'
S> ", cnn, adOpenKeyset, adLockPessimistic

Open separate ADO connection for your recordset. CurrentProject.Connection
is not pure ADO, its provider is not OLEDB.

Note that you won't be able to use recordsets with pessimistic locking as
recordsets of Access objects (forms, combo. etc).

Vadim
 
Back
Top