Click here to Skip to main content
15,891,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have created an application in Vb.net with SQL Server as Database which works fine
on single PC. But Currently, it is installed on Multiple PCs with a central Database. Multiple users are using over LAN Environment and if suppose they work on the same screen and save a transaction at the same time the Transaction ID Field is duplicated. The Transaction ID Field is set to varchar (predefined format like S000001) in the database.

How to resolve this issue, Please Help as I am a beginner in development.

Thanks.
Posted
Comments
Maciej Los 9-May-12 4:16am    
Why ID field is set to varchar? If the predefined format is: S000001 try to add additional field like HelpId int and set it as autoincrement.

You need to look into your DB design. If inserting a record is creating a duplicate key, then there is some serious issue. Short term fix can be using Transactions. Either at SQL level or code level.

Here:
MSDN: BEGIN TRANSACTION (Transact-SQL)[^]
SQL Server Transactions and Error Handling[^]

MSDN: Local Transactions[^]
Using Transactions in ADO.NET[^]
 
Share this answer
 
Comments
Maciej Los 9-May-12 4:11am    
Good answer, my 5!
Sandeep Mewara 9-May-12 4:46am    
Thanks.
This sounds like you're trying to generate a surrogate key by your code. If that's the case, don't do it.

Instead use the database to create a unique value, for example uniqueidentifier[^].

Also if not already done so, you should define this column as the primary or secondary key.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900