Wrox Programmer Forums
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Dreamweaver (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 20th, 2005, 11:16 AM
Friend of Wrox
Join Date: May 2005
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hastikeyvan
Default need help again

Hello all
if we want to check all the recordset and fine the biggest Row(Row is one of the columns in database)can we write such code?
<%Dim i,a
                 while not rs.eof
                if (rs("Row")>i) then
                 end if
when i run this it gives me always "1"
where is my mistake?

Old December 20th, 2005, 12:05 PM
Registered User
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

Firstly, it looks like you're setting i to be a string value of "0" rather than a numeric value of 0, which means you may be getting strange results when running a comparison.

Secondly, if you're looking for the highest value in a column of a table in a database (assuming that table holds numeric values) isn't it better to run a SQL statement to do this in one operation rather than iterating through a recordset?

The SQL statement would be something like:

SELECT MAX(Row) from [table name]

Of course it would be a better idea to put this in a stored procedure and return the result from that, as it's always much lower risk running a stored procedure rather than hard coding SQL in your ASP.

SELECT MAX(Row) FROM [table name]

This is assuming SQL server as the database, change code appropriately for other RDBMS of course.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.