Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

left zeros disapear ???

Status
Not open for further replies.

RicardoPereira

Programmer
Jun 3, 2003
255
PT
I have a search page that gets data from an sql server database. My problem is when i search values with left zeros in the begin of the string, they simple disapear.
Example: if i have in the database this string "010505" it appear like "10505".
Why did this happen ?

Thanks
Ricardo
 
because its a numeric field (i guess), if the database field is varchar in nature that wont happen...

Known is handfull, Unknown is worldfull
 
Hi,

This is what might be happening while you are reading for the database

Code:
 String intValue = "01234";
 System.out.println("intValue as int |" +Integer.parseInt(intValue));
 System.out.println("intValue as String |" +intValue);

 /*
  output is
  intValue as int |1234
  intValue as String |01234
 */

Cheers
Venu
 
I think that the problem is when i request the parameter.
When i request the parameter 010101 it only assumes 10101.
 
If the field is numeric how do i solve this problem ?
How can i put the left zero in the database ?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top