Click here to Skip to main content
15,902,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to generate automatic serial number? I've used this query:
select isnull(max(BL_DueNo)+1,1) from BillForm where BL_Lno='" + BL_LnoCombo.Text + "'

But it doesn't generate after 10. Please tell me the correct sql query.
Updated 5-Jan-11 19:43pm

1 solution

Because you're fetching maximum among where BL_Lno is from provided value.
and in the your scenario you need to find MAX from all record.

See if BL_Lno having a value of 9 and you're incrementing it with 10, But do you know that there's alerady a record for ID 9 for other BL_LnoCombo?

If you want to generate the incremental no then don't go with custom generation, USE Auto Increment column[^] that will take care itself.
Share this answer
JOAT-MON 6-Jan-11 4:05am    
+5: And if there is any reason you cannot use the Auto Increment column, then you can just remove the where clause. :)

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