ADO overwriting locked record problem

G

Guest

Hi all,

I have a problem with ADO. I am updating a ADO recordset in a multi-user
environment but somehow it seems that the code I am using is ignoring locks
by other users.

This is the code I am using

dim cnx as ADODB.connection
dim myRs as ADODB.recordset

set cnx = currentproject.connection
set myrs = new adodb.recordset
cnx.BeginTrans

With rs
.Fields("FIELD1") = "VALUE1"
.Update
End With

If cnx.Errors.Count <> 0 Or Err.Number <> 0 Then
cnx.RollbackTrans
Else
cnx.CommitTrans
End If

Somehow this code seem to update the table, although someone else is already
updating the table (and locking the record via another instance). I can not
figure out why!!!! Can anybody please help?

TIA
 
D

Dirk Goldgar

In
Brotha Lee said:
Hi all,

I have a problem with ADO. I am updating a ADO recordset in a
multi-user environment but somehow it seems that the code I am using
is ignoring locks by other users.

This is the code I am using

dim cnx as ADODB.connection
dim myRs as ADODB.recordset

set cnx = currentproject.connection
set myrs = new adodb.recordset
cnx.BeginTrans

With rs
.Fields("FIELD1") = "VALUE1"
.Update
End With

If cnx.Errors.Count <> 0 Or Err.Number <> 0 Then
cnx.RollbackTrans
Else
cnx.CommitTrans
End If

That's not your code. It's obviously a transcription of part of the
code. If there were something relevant in the code you omitted, we
wouldn't know about it.
Somehow this code seem to update the table, although someone else is
already updating the table (and locking the record via another
instance). I can not figure out why!!!! Can anybody please help?

How do you know that the record is locked by another user? If the other
user is editing the record but using optimistic locking, then the record
won't be locked until the moment that the user saves the record.
 
J

Jamie Collins

How do you know that the record is locked by another user? If the other
user is editing the record but using optimistic locking

Hint for the OP: test the recordset object's LockType property *after*
it has been opened you may *think* it is adLockPessimistic...)

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top