kanden
asked on
SQLServer and ASP.net (using identity)
I need to set the identity so that it shows 5 digits 00001. I'm not sure what the best method is.
Should I leave the identity seed at 1 and only show the zeros on the .net page.
or
Is there a way to get SQL Server to seed showing the zeros??
Thanks
Should I leave the identity seed at 1 and only show the zeros on the .net page.
or
Is there a way to get SQL Server to seed showing the zeros??
Thanks
I recomment to fill the spaces that you need with strVariable.padLeft(5,"0") , in that way you still have the clarity of your dataBase design... well, thats my opinion.
ASKER
That will work but what do I do when the identity gets to 2 digits that whould produce 000012 that whould make the number 6 digits instead of five. Is there a way to script this?
Gary
Gary
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That works except it puts 4 zeros regardless of how many digits the identity is.
I need a max of 5 digits zeros plus the identity. example 00125 or 00001 or 12345
Thanks
Gary
I need a max of 5 digits zeros plus the identity. example 00125 or 00001 or 12345
Thanks
Gary
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In VB.NET
Dim myInt1 As Integer = 11
Dim myInt2 As Integer = 12345
Dim s1 As String = myInt1.ToString("00000") // returns 00011
Dim s2 As String = myInt2.ToString("00000") // returns 12345
Dim myInt1 As Integer = 11
Dim myInt2 As Integer = 12345
Dim s1 As String = myInt1.ToString("00000") // returns 00011
Dim s2 As String = myInt2.ToString("00000") // returns 12345
jeje... that thing you didn't say with your comment:
"That will work but what do I do when the identity gets to 2 digits that whould produce 000012 that whould make the number 6 digits instead of five. Is there a way to script this?"
you asked for a 6 digits, well, anyway the problem is solved.
"That will work but what do I do when the identity gets to 2 digits that whould produce 000012 that whould make the number 6 digits instead of five. Is there a way to script this?"
you asked for a 6 digits, well, anyway the problem is solved.