Solved

Locking records in a multiuser environment

Posted on 2004-08-30
5
142 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:eskill
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:KarcOrigin
ID: 11929401
Which DB you are using at the back end?
0
 
LVL 5

Expert Comment

by:KarcOrigin
ID: 11929417

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!
0
 
LVL 5

Accepted Solution

by:
Z03niE earned 125 total points
ID: 11929443
If the id field is the primary key, the table would automatically reject duplicate value.
If you still want to make sure, if you are using MS SQL, you can create a stored procedure to handle the insert, update and delete process.
In the stored procedure, do the insert stuff inside a transaction , the transaction will lock the table temporaryly until it is committed. And also during the transaction check for duplicate value before updating the table.
Hope that help.
0
 

Author Comment

by:eskill
ID: 11929548
I am using MSAccess 2000 as the back end
0
 
LVL 5

Expert Comment

by:Z03niE
ID: 11929581
Maybe this will help.
In the field property set indexed value to Yes (No Duplicates).
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question