Click here to Skip to main content
15,881,712 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am using a rad masked textbox for numeric inputs. When I pass the value to database the preceding 0 if any is automatically truncated. I also tried rad numeric text box but it also truncates the preceding 0 even before passing the value to database. In my db i have a column to accept 6 digits from 0-9 each. I have check constraints defined for that and the value cannot be less than 6 digits. So if the input from rad numeric text box or masked text box starts from 0 like 012345, the 0 automatically gets truncated in rad numeric text box.
when using masked text box the control passes the value as 012345 but sql server truncates the preceding 0.

Pls help to resolve the issue.

Note: Clients does to want to use javascript for validation...

Thanks in advance...

Thanks Aday and Griff for ur comment and suggestion but the issue is quite dubious. I can't change the database structure of the table to accept string. So what I need is to pass the value as integer to the database. Let me clarify u...

Some vendor entered a 6 digit (012345) no to the radmasked text box or radnumeric textbox. So when i pass the value to the stored proc for insert statement it must me passed as integer..
1. if sql truncates leading zeros (01 =1) what is the solution as I have to store all six digits or else check constraint for the column will give error?

2. If sql does not truncate the leading zero then int.parse(radmaskedtextbox1.text) will convert it into 012345 or 12345?

If u can clarify.. It will be a great help...
Posted
Updated 8-Sep-12 7:38am
v2
Comments
[no name] 8-Sep-12 11:23am    
What issue? 012345 = 12345. 01 = 1, 001 = 1. If you want to store the string 012345 in the database then change your table to accept a string.

1 solution

Numbers are numbers are numbers.
1 is the same as 0000001 is the same as 000000000000000000000000000000000000000000000000000000000000000000000001 as far as an integer, or an integer parser is concerned - leading zeros do not count.
If you must pass a six digit value to SQL, then it must either not have any leading zeroes, or it must bne passed as a string - any conversion to an integer value at all will discard any number of leading zeroes.
 
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