Link to home
Start Free TrialLog in
Avatar of eskill
eskill

asked on

Locking records in a multiuser environment

hello everybody,

I am trying to create a vb appln that will be used in a multi user environment.

i have a table with fields like
1. id - number
2. name - text

i get duplicate id's when more than one user tries to update that table.

how to resolve this concurrency problem?

plz help me out.

thanks in advance
sarni
Avatar of KarcOrigin
KarcOrigin

Which DB you are using at the back end?

In any case, A better solution is to use SELECT...FOR UPDATE to lock the selected rows. Another user cannot modify the row between the SELECT...FOR UPDATE and UPDATE. In fact, the row remains locked until the transaction ends.


Eg:

SELECT * FROM Test WHERE name = 'karc' FOR UPDATE;

UPDATE Test SET name = 'Origin' WHERE name = 'karc';

I hope it helps you.

Cheers!
ASKER CERTIFIED SOLUTION
Avatar of Z03niE
Z03niE

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eskill

ASKER

I am using MSAccess 2000 as the back end
Maybe this will help.
In the field property set indexed value to Yes (No Duplicates).