Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generating Consecutive Numbers
Message
 
To
17/03/2010 15:15:26
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01455132
Message ID:
01455189
Views:
41
>>>>Hi,
>>>>
>>>>how do I generate consecutive numbers (for use as a customer number for example)? Is there anything in the framework that achieves this? I found reference to a function that autoincrements values, but it appears to b eonly on Primary Keys, this field is a candidate key.
>>>
>>>I used to have a foxpro method that did that. Oh wait, it was a Open Access method. That goes back a few years. It would be pretty easy to do it Frank if you wanted to I could dig up some old code. The one I did was used to create Permit numbers where I didn't want to skip any numbers like so many of them do if an order is canceled. I wrote my own that didn't skip. The complication on your situation is going to be since you also allow the user to enter what they want is you will have to generate your next valid number and also verify it doesn't already exist..
>>>
>>>I haven't heard back yet about if the framework has a way to hook into the autoincrement and at some point I will poke around to see if it is possible. I suspect it is a mechanism of the dataset stuff.
>>>
>>>Let me know if you want any of my old code that would help with making your own method.
>>>Tim
>>
>>What database are you using?
>>
>>SQL Server has the Identity type column - autoincrements w/o any client code.
>
>William,
>
>as I am the one with trouble, I guess you meant to ask me :)
>
>I am using SQL Server 2008 and have a thread here already on trying this with Identity fields. The problem is that I leave the field open for the user to enter a value, if they do not enter a value, then I want to generate the next consecutive value. I also encountered some issues with the Identity fields and the MM.NET framework which I was unable to understand.

OK. Identity columns are really meant to be strictly database generated. There is an option (Set Identity_Insert ON) that will allow you to override that, but that will very likely lead to more trouble than it is worth.

Are you always letting a user enter this field (and expecting it to be unique), or is that just for an administrative function in order to properly match a foreign key? If it is just for administrative use, then Set Identity_Insert on may be do-able.

I wouldn't know where to start in the MM.NET framework. I actually bought several licenses for it a couple of years ago for a project, but the MM framework simply was not compatible with that database structure so the licenses went in the drawer... :(
____________________________________

Don't Tread on Me

Overthrow the federal government NOW!
____________________________________
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform