Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 17th, 2003, 05:40 AM
Jon Jon is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: London
Posts: 6 Jon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 58 m 13 sec
Reputation Power: 0
Question table in ascending order?

How do I order a table in ascending order?
the code below works fine until the ActivityID goes above 9!

the code below orders the data in the table in the following way

1,10,2,3,4,5,6,7,8,9

as you can see when I add 1 to the last entry in the list I get 10 again (9+1=10) the code then try’s to enter a duplicate key field into the table.

How can I get the table to produce the following results

1,2,3,4,5,6,7,8,9,10.........

Source code:

sqlstr = "SELECT ActivityID FROM tblActivity ORDER BY ActivityID DESC"

rs.open sqlstr, conn, 1,1
rs.movefirst
dim lastid
lastid = rs("activityid")
rs.close
rs("activityid") = lastid + 1


Many thanks in advance,

Cheers
Jon

Reply With Quote
  #2  
Old October 17th, 2003, 05:15 PM
dcarva's Avatar
dcarva dcarva is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 633 dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 18 m 20 sec
Reputation Power: 6
If your fields are defined as integers, then it will sort as you expect. So set your field types as "int". If not, you need to convert the field using CONVERT or CAST.

Reply With Quote
  #3  
Old October 21st, 2003, 04:15 AM
Jon Jon is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: London
Posts: 6 Jon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 58 m 13 sec
Reputation Power: 0
Thank you for your reply.

The change in the table properties you suggested has worked fine.

Regards,

Jon

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > table in ascending order?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT