Reply
How does asp treat numbers?
Old 08-14-2008, 08:04 PM How does asp treat numbers?
Super Talker

Posts: 120
Trades: 0
I have an database, and one column will have a number 1-10.

When I shop them ordered by that number, will they propery show

1
2
3
4
5
6
7
8
9
10

or do it wrong, like some things do when alphabetizing:

1
10
2
3
4
5
6
7
8
9

What do you think I should do?

Should i do 0-9?

should they be 01, 02, 03, ect.?

There may be more than 10 later.
Skeddles is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 08-15-2008, 08:16 AM Re: How does asp treat numbers?
Average Talker

Posts: 25
Name: David Hamsterdam
Trades: 0
It depends upon the coding. You can manage it by using if else statement. If you declare it as a char type, the result: 1, 10, 11, 12 ..... but for numbers, the result: 1,2,3,4......
cyberseren is offline
Reply With Quote
View Public Profile
 
Old 08-15-2008, 08:27 AM Re: How does asp treat numbers?
Extreme Talker

Posts: 212
Trades: 0
why don't use 01 02 03 04 05 06 07 08 09 10 etc?
I think that will be working in any case.
SeemsOk is offline
Reply With Quote
View Public Profile
 
Old 08-16-2008, 10:37 AM Re: How does asp treat numbers?
chrishirst's Avatar
Super Moderator

Posts: 22,257
Location: Blackpool. UK
Trades: 0
IF they are REALLY numbers. It doesn't matter, and they will show in the correct numeric order with or without a leading zero

HOWEVER

If they are strings of number characters you will need a leading zero as then they will be sorted in ASCII value order.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-18-2008, 01:53 AM
itHighway's Avatar
Skilled Talker

Posts: 73
Name: Zeeshan Dar
Location: GUJ
Trades: 0
You have to change the field type to Numeric in database. This is resolve the sorting issue when browsing the products on web interface.

If you are using the MS Access database then you will have to change the field type in database and if MS Sql then you can convert the field type in sql query.

Last edited by chrishirst; 08-18-2008 at 03:56 AM.. Reason: followon post merged
itHighway is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 06:26 AM Re: How does asp treat numbers?
Super Talker

Posts: 102
Location: http://www.isquaretechnologies.com
Trades: 0
If the column type is Numeric(Integer) then it will give you the results as 1,2,3.. etc and If you have column type Text(Varchar) then it will give you the results as 1,10,2,3... etc
__________________
saurabhj is offline
Reply With Quote
View Public Profile Visit saurabhj's homepage!
 
Old 08-19-2008, 04:06 PM Re: How does asp treat numbers?
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,674
Name: John Alexander
Trades: 0
Chris Hirst has the right answer. As strings, it goes 1, 2, 20, 25, 3, 35, 4, and so on. If you sort them as numbers, you'll avoid this, and if you must sort them as strings, prefix them to a set width, as 001, 002, 020, and so on.
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How does asp treat numbers?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.13045 seconds with 13 queries