I have several form which will show a list with a sequential order number like 1,2,3,4, etc. (See picture below). I want this field LineOrder to be autogenerated with the next unused value when a new record is created, so if the last one used is 5, then when clicking New, the value will be 6.
I added the following code in the PaymentMethodBO.vb:
nextLineOrder =
nextLineOrder = 1
So far this is working fine, but I would like to make sure this is the proper way to get this done when working with data in the BO. I guess I may have another BO with a SELECT MAX() statement to get the last value used and then increment this value. So I would appreciate any recommendation in this regard.
Thanks!
Thanks for your reply. Yes I see that you can have the second Auto Increment using the DDT package which I also tried to do and see below image. Right now I am NOT using yet the DDT package and I tried to create the second auto increment in the actual ms sql 2005 table. As far as I know it can not be accomplished unless you use a Stored Procedure. I assune the DDT also created a Stored Procedure for this purpose.
Thanks,Doron
In SQL Server, this is called an identity column. You can technically setup as many of these as you need. If you modify a table through SSMS, you can go down to the Identity section, and specify an auto-increment seed, etc.
http://www.dfarber.com/Counter.rar (it is 1.7 mb)and Video worth a thousands words.
Regards,
Doron