Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VBVB.NET
Hello there.
 
Is there a way to maintain the format of a number in this form:
 
00238
00250
 
Initially those numbers are a string in the project and they are saved as varchar in my database, but I need to generate a consecutive serial from those two, to achieve that I pass the numbers to int, but with this the leading zeros are obviously removed.
Is just to clear my curiosity about it, I already save all the serials into the database with the leading zeros but I made this taking the length of the original string and making a comparison of the serial generated with the original.
 
Thanks in advance
Posted 21-Feb-13 4:42am
Edited 21-Feb-13 4:49am
v2
Comments
CHill60 at 21-Feb-13 11:10am
   
Just a thought - you will get better database performance if you stored these "numbers" as integers on the database. You will also future-proof yourself against the serial number clocking past 99999. You can always display/print them in the varchar format when required. Another advantage would be being able to have the d/base column defined with IDENTITY(1,1) meaning that the serial will be automatically incremented for you each time you add a row
EddyGuzman at 21-Feb-13 11:42am
   
Oh! Yes I know, I was saving them as Integers at start, problem is that this numbers are consecutive serials, so if I remove the zeros the serial will be incorrect. But your comment is absolutely valid.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Dnyaneshwar@Pune 1,300
1 Sergey Alexandrovich Kryukov 660
2 OriginalGriff 329
3 ravikhoda 300
4 Manas Bhardwaj 240
0 Sergey Alexandrovich Kryukov 11,194
1 OriginalGriff 6,867
2 Peter Leow 4,795
3 Abhinav S 3,838
4 Maciej Los 3,575


Advertise | Privacy | Mobile
Web01 | 2.8.140421.2 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid