Click here to Skip to main content
15,898,849 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have one field of serial number in database...but it's datatype is char(10)..from that how can i genrate 10 digit number and that number display in label
Posted
Comments
Sergey Alexandrovich Kryukov 1-Jul-13 11:24am    
Please start from http://www.whathaveyoutried.com.
—SA
Richard MacCutchan 1-Jul-13 11:39am    
Easy, think of a number above 999,999,999, and convert it to a string.
Shibashish_Choudhury 1-Jul-13 12:11pm    
please explain the need of doing this....

1 solution

Don't try.
If you are storing it as a text field, then leave it as a text field - a label can only display those, so converting the data to a numeric value just to convert it back to a string again to display it is wasteful.

But if it is always a numeric value, then why are you storing it in a text fields anyway? If it contains a single non-numeric digit then any conversion to a number will fail...

10 digit numbers are a minor problem to store: unless the number is below 4,294,967,296 if won't fit in even an unsigned 32 bit integer, so you would have to process it as a 64 bit number - a long in C# or a bigint in SQL server. But that's what I'd do. If it's a numeric value, store it as a numeric value - it's a lot easier (and smaller) to work with.
 
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