Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I wanted to Generate the sequence of userid in an alphanumeric format. How do i achieve this
Ex:
User1 ID:Abc01
User2 Id:Abc02
User3 Id:Abc03

Please find me the solution.
Posted
Updated 26-Oct-12 10:58am
v2

use static int variable and make increment in that then concnate with string you want. save the last value in db if you want to preserve it

Thanks,
Ambesha
 
Share this answer
 
Comments
fjdiewornncalwe 26-Oct-12 16:44pm    
My vote of 2: Way too much overhead in doing it this way and causes more problems than it solves. See my answer for a cleaner way to achieve this.
This is quite simply a very bad idea. What is the point of the "Abc" in the user id? If you need a two part identifier, you should use a two column primary key instead where one is autoincrement and holds the numeric part while the second holds the alpha portion and is manually inserted with the insert statement. Much less of a coding headache this way and the work gets pushed to the db server.
 
Share this answer
 

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