navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Extra spaces in db field

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Extra spaces in db field
Page: [1]
 
carrie

 

Posts: 237
From: Port Orange, FL Volusia
Status: offline

 
Extra spaces in db field - 6/25/2008 14:11:12   
Hi all,

I am pulling data from a MYSQL db with asp and I've noticed it has extra spaces to the left of the value that I can't seem to trim.
One example is a field marked: Agent ID CHAR 9, but it only has 6 - 7 numbers in the field. So, some fields will have 2 spaces, and some will have three, to the left of the number.
When I use the 'trim' feature like this, it does not remove the spaces:
agentnamestr = trim(ors("Agent ID")).
I don't know why the field has spaces in the first place, but it does. How can I get the spaces removed from the query results?

Carrie
swoosh

 

Posts: 1436
Joined: 5/18/2002
From: Beaver Falls, PA
Status: offline

 
RE: Extra spaces in db field - 6/25/2008 15:38:19   
quote:

don't know why the field has spaces in the first place


CHAR 9 would mean 9 characters.

The char is a fixed-length character data type, the varchar is a variable-length character data type.

Because char is a fixed-length data type, the storage size of the char value is equal to the maximum size for this column. Because varchar is a variable-length data type, the storage size of the varchar value is the actual length of the data entered, not the maximum size for this column.

You can use char when the data entries in a column are expected to be the same size.
You can use varchar when the data entries in a column are expected to vary considerably in size.



_____________________________

Swoooosh
Just Do It!


(in reply to carrie)
carrie

 

Posts: 237
From: Port Orange, FL Volusia
Status: offline

 
RE: Extra spaces in db field - 6/25/2008 15:53:53   
Thanks swoosh. I get an index file to load the data into the MySQL db, and that is the way that field is labeled (as well as several others). So I see that if I just change the data type of that field, and reload the data into the MySQL db, then then the spaces will disappear before I run queries.

Excellent!

Thanks again!

Carrie

(in reply to swoosh)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Extra spaces in db field
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts