ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

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 Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 20th, 2003, 10:48 PM
vb.net vb.net is offline
Demonic Swordsman DGQB
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Posts: 995 vb.net User rank is Second Lieutenant (5000 - 10000 Reputation Level)vb.net User rank is Second Lieutenant (5000 - 10000 Reputation Level)vb.net User rank is Second Lieutenant (5000 - 10000 Reputation Level)vb.net User rank is Second Lieutenant (5000 - 10000 Reputation Level)vb.net User rank is Second Lieutenant (5000 - 10000 Reputation Level)vb.net User rank is Second Lieutenant (5000 - 10000 Reputation Level)vb.net User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 12 h 38 m 28 sec
Reputation Power: 76
Counting the max(mainID) in ASP

Hi!

I need to count the max value of the mainID of my database before I iterate through the other values of the database. For example, consider this page: http://pjshimmer.homeunix.com/asp/movies.asp

As you can see, I put a ¤ symbol next to the latest 20 movies. The latest 20 movies are determined by the formula max(mainID) - 20. The SQL for selecting the max value is select max(mainID) from Table - very simple. Can someone help me set this up in ASP? I have had no luck so far.

What I currently do is iterating through the database twice - first time JUST to get the max value:

Code:
			dim counter

			Do While Not recset_spare.EOF
					counter=counter+1
					recset_spare.MoveNext
			loop
			recset_spare.Close


I would like to avoid this step if possible. Any suggestions?

Reply With Quote
  #2  
Old July 20th, 2003, 10:53 PM
nopoints nopoints is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Windsor ON, Canada
Posts: 459 nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 44 m 22 sec
Reputation Power: 8
use this sql:
Code:
select max(mainID) as MaxMainID from Table

then open the recordset. then use:
Code:
recset_spare.Fields.Item("MaxMainID").Value
__________________
Programmer's Corner

Last edited by nopoints : July 20th, 2003 at 10:57 PM.

Reply With Quote
  #3  
Old July 23rd, 2003, 08:18 PM
vb.net vb.net is offline
Demonic Swordsman DGQB
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Posts: 995 vb.net User rank is Second Lieutenant (5000 - 10000 Reputation Level)vb.net User rank is Second Lieutenant (5000 - 10000 Reputation Level)vb.net User rank is Second Lieutenant (5000 - 10000 Reputation Level)vb.net User rank is Second Lieutenant (5000 - 10000 Reputation Level)vb.net User rank is Second Lieutenant (5000 - 10000 Reputation Level)vb.net User rank is Second Lieutenant (5000 - 10000 Reputation Level)vb.net User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 12 h 38 m 28 sec
Reputation Power: 76
Thank you for your help! It has been most appreciated.

Reply With Quote
  #4  
Old July 24th, 2003, 02:24 AM
Shad Shad is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 24 Shad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Or you could do

Code:
SELECT TOP 1 MainID FROM Table ORDER BY MainID DESC
...though I think they're much the same

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Counting the max(mainID) in ASP


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 1 hosted by Hostway