Hi
I am developing program in VB.NET that would be used by 10 users concurrently. Each of them can save a receipt to the table RECEIPT in SQL Server 2000. Every time a new receipt is added should take a number equal to the last receipt number plus One.
first I got the last Receipt number with
SELECT MAX(ID) LAST_ID FROM RECEIPT
and add one to it
then
I execute Non Query command to add the new receipt with the new ID
INSERT INTO RECEIPT (ID,CUSTOMERID, .....etc
The problem when two of the users try to add receipts at the same time then there is a chance that a primary key conflict. would take place and will get error. How can I handle this matter and make sure even if the ten users tried to add receipt at the same time, it will work
Regards