Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Locking records in a multiuser environment

Posted on 2004-08-30
5
Medium Priority
?
145 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 500 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

722 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