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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm loosing my zeros

Status
Not open for further replies.

streborr

IS-IT--Management
Jan 16, 2002
98
Some of our customer numbers have zeros in them, 012345.
When I retrieve the record the zeros are gone.
How do I keep the zeros in the left part of the string?

(all customer number are to have a length of 6)

Thanks,
Rick
 
Where are you loosing the zeros (database, web page etc)
 
When I retrieve the record from a database the customer number no longer has the zeros that I entered originally.

example:
entered - 001234

returned - 1234

Thanks
 
are you treating them as a number or a string. If you treat them as a number you will loose the leading zeros. I would suggest treating them as a string with quotes. That way you will retain the leading zeros.

Roj
 
Sorry I was a little quick on the submit button. The other thing you could do if you don't want to treat your numbers as text is to just add on zeros to make your string 6 digits.

Roj
 
There could be several problems.
First if the database for that value is an integer, you will loose the zero in the database. If this is the case then you need to change the value to varchar(or char)

Assuming the value in the database is a varchar:
if you are pulling the value out in an asp page and you are using either cint(theValue) or clng(theValue) then you will loose the zero's.
 
The number is being saved into the DB as text.

I just used this:

dim custnum, num, pad
pad = "000000000000"
num = trim(rsADO("dist_no"))
custnum = pad & num
custnum = right(custnum,6)

Thanks for your help guys,
Rick
 
I guess I am still missing something...Do the zeros show up in your database?
 
I checked the DB and no the zeros are not in there, and the field is a text field.

Rick
 
I have had this happen to me. You should check your insertion code and make sure that you are putting the whole number in "" that way you will retain the zeros.

Roj
 
Sorry, I guess I failed to mention when I entered the following code that it now does what I need.

dim custnum, num, pad
pad = "000000000000"
num = trim(rsADO("dist_no"))
custnum = pad & num
custnum = right(custnum,6)

Thanks for your help Roj,
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top