Is anybody know how to genarate the next primary-key number automatically, stored in a data-base on my c# application.???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Is anybody know how to genarate the next primary-key number automatically, stored in a data-base on my c# application.????

i want to genarate the next invoice number automatically when my form is loaded..the invoice number is the primary-key of the invoice table in the data-base....is anybody know how to do that????plz helpz........

8th Jul 2017, 8:37 AM
Madusha Gunawardana
Madusha Gunawardana - avatar
2 Answers
+ 4
select max(invoice_number) + 1 from invoice Use that for the next invoice number? it is auto-increment? sorry if I misunderstood you.
8th Jul 2017, 8:51 AM
Ipang
+ 1
Another alternative is "SELECT IDENT_CURRENT('tablename')" in SQL SERVER.
8th Jul 2017, 4:36 PM
Ariel Cani
Ariel Cani - avatar