Click here to Skip to main content
15,898,588 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
Hello all there,

How i can get an invoice id for my POS next Customer each time i submit my order. I have a field name ID in SQL that is auto increment. But it is generating on the time of submission of database while i need Invoice id on POS on completion of previous customer.

Thanks in advance

Jazaib
Posted
Comments
Sergey Alexandrovich Kryukov 11-Jun-13 17:36pm    
It all depends on how you define "next customer". Next — in what sequence? And, is is single user database? If not, you might be in trouble. Apparently, the user identity should be related to the workflow of the person using the UI. When a user is created, it always have the ID.
—SA
PIEBALDconsult 11-Jun-13 18:02pm    
"i need Invoice id on POS on completion of previous customer."

No, you don't. How do you know there'll even be a next customer?

You cannot reliably get the "next" id from the database in a multiuser system.

Think about it. You have 2 clients going to the database at the same time. Each gets the "next" id from the table. They both try to commit a new invoice to the table. One will work and the other will fail because the ID is already in use.
 
Share this answer
 
Comments
Jaa Zaib 11-Jun-13 17:55pm    
Hay Thanks for replying.
Yes i have multi user system. Same problem i am facing when trying to insert records in sales tables. how i can get ride of the problem ??
Thanks
Dave Kreskowiak 11-Jun-13 18:44pm    
There is no solution. You cannot get the next record ID. Period.

The only way to get the nxt ID reliably is to insert an invoice.
You could insert a blank record in your database, then use that ID. If they cancel the transaction, delete the record from the database. That's really the only reliable way to reserve an ID in a database thats multi-user.
 
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