|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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? |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
Thank you for your help! It has been most appreciated.
|
|
#4
|
|||
|
|||
|
Or you could do
Code:
SELECT TOP 1 MainID FROM Table ORDER BY MainID DESC ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Counting the max(mainID) in ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|