473,583 Members | 4,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding the maximum value in a recordset column

How do I find the maximum value of a recordset column? I'd rather do it
this way than open a new recordset with Max(column).

Thanks in anticipation.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Oct 13 '05 #1
2 10341
Roger Withnell wrote:
How do I find the maximum value of a recordset column? I'd rather do
it this way than open a new recordset with Max(column).

Thanks in anticipation.


My preference would be to let the database (whatever it is) do this. If
using sql server, I would write a stored procedure that returned the
records, as well as returning the max(column) in an output parameter. If
Access, I would still make a second trip to the database.

However, what you can do is:

1. Optional but highly recommended: disconnect the recordset by setting its
ActiveConnectio n property to Nothing. This will allow you to close and
destroy your Connection object, freeing it up for another thread to use

2. Use the recordset's Sort property to sort by the column you wish to find
the max value of.

3. Move to the first or last record (depending on the sort direction you
used) and read the value.

HTH,
Bob barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Oct 13 '05 #2
If you're looping through the recordset with your ASP code and then
showing the max after all that I'd suggest something similar to a
running sum ASP variable. But of course this would check each value and
only make a change if it's larger than the current value:

If objRS("TheValue ") > MyMaxVariable Then
MyMaxVariable = objRS("TheValue ")
End If

Best regards,
J. Paul Schmidt, Freelance Web and Database Developer
http://www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips

<<
How do I find the maximum value of a recordset column? I'd rather do it
this way than open a new recordset with Max(column).

Thanks in anticipation.


*** Sent via Developersdex http://www.developersdex.com ***
Oct 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
10119
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
9
3944
by: Hamster | last post by:
I need to display data like this: CompanyName1 Company | Date| Transactions Count -- headers CompanyName1 | Date| 1 -- data CompanyName2 | Date| 5 -- data CompanyName3 | Date| 2 -- data CompanyName4 | Date| 7 -- data
2
2320
by: Hennie de Nooijer | last post by:
Because of an error in google or underlying site i can reply on my own issue. Therefore i copied the former entered message in this message. -------------------------------------REPY---------------------------------- Hi Maybe i wasn't clear. I want to dynamically check whether what the lowest date and the highest date is in the calendar table....
2
2210
by: TadPole | last post by:
Hi all, My main problems are::::::::: 1. Set a value within a block container that can be used and changed by subsequent templates/block-containers/tables etc.. 2. get/determine/find the setting that tell the process that the new top of the document region is now at the end of the last block-container used, this must be set in that last...
2
28555
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
6
9642
by: Dave Hopper | last post by:
Hi I am using the following SQL to retrieve a value in a list box using a unique ID held in the list box call cntID. The list box is used on an order form to list appointments that have been made for service staff. My problem is the SQL is not retrieving the value of the listbox. I have tested the SQL by entering a fixed value of a...
2
2690
by: MyGreatProgramme | last post by:
I want to make a delete query that deletes all the items that are in the minorty. For example, in the field " Houses " there are 10 rows with value 1 , 3 rows with value 3 and 4 rows with value 6. In this case I must delete all values except the value 1 I suppose the code should use Dcount, Max or something like that but I cannot do it....
15
17514
by: timothytoe | last post by:
Situation: I have an array of objects. I want to find the maximum value of a given numeric value that exists in each of the objects. Suppose the array of objects is called "stat" and the numeric value I want to check is called "member". Obviously, a for loop would do it: var maximum=stat.member;
7
6993
by: laredotornado | last post by:
Hi, I'm using PHP 5 with MySql 5. I have a MySQL InnoDB table with a column of type INTEGER UNSIGNED. Is there a constant in PHP to insert the maximum value possible into the column? The underlying OS is Red Hat Linux, but I'm not sure about the version. Any help you can provide is appreciated, - Dave
0
7825
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7933
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5372
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3816
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3841
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1431
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1155
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.