Unique ID Generator
-
Hello I have been trying to development a id generator but don't know exactly how to do it. The id must have an abbreviation + year(05) + id ie. refernce=abbrev+05+id. If anyone can give some advice on this it is much appreciated. Also if it helps the abbrev comes from a database on sql server. Thank You Paul Mc Gann gfhg
-
Hello I have been trying to development a id generator but don't know exactly how to do it. The id must have an abbreviation + year(05) + id ie. refernce=abbrev+05+id. If anyone can give some advice on this it is much appreciated. Also if it helps the abbrev comes from a database on sql server. Thank You Paul Mc Gann gfhg
I'm not exactly clear on what you mean by "id" generator. You're using "id" to refer to the entire reference (abbrev+05+id) and as the last part of the reference. Are you asking how to concatenate abbrev, 05 and id? Or how to generate a unique string to tag onto the end of the reference? Or what? Do or not do. There is no try.
-
Hello I have been trying to development a id generator but don't know exactly how to do it. The id must have an abbreviation + year(05) + id ie. refernce=abbrev+05+id. If anyone can give some advice on this it is much appreciated. Also if it helps the abbrev comes from a database on sql server. Thank You Paul Mc Gann gfhg
How about making an idGen table, with an auto_increment column in it:
Create table idGen (GenID int not null auto_increment, Abbrev varchar(3), Year char(2))
Then, when you need a new Unique ID, insert into this table and retrieve the id inserted:Insert into idGen (Abbrev, Year) values ('AA', '05') select Abbrev + Year + ltrim(str(GenID)) where GenID = @@identity
Roy. -
Hello I have been trying to development a id generator but don't know exactly how to do it. The id must have an abbreviation + year(05) + id ie. refernce=abbrev+05+id. If anyone can give some advice on this it is much appreciated. Also if it helps the abbrev comes from a database on sql server. Thank You Paul Mc Gann gfhg
Hey Paul, AS I Understand you want code to generate the unique Id So here is the code
Public Function GenerateID() As String Dim length As Integer Dim guidResult As String length = 10 guidResult = System.Guid.NewGuid().ToString() 'removes the hyphen guidResult = guidResult.Replace("-", String.Empty) Return guidResult.Substring(0, length) End Function
BY this code you can generate the desired length Unique ID Hope this works for you. Hema Chaudhry