|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Getting The Avg Number from a Recordset?
I am using the code below to count the number of records and divide it by the sum of the records to get the average number. I get the error : Type mismatch: 'ubound'
I know I'm missing something obvious as my experience with arrays have rendered below. Any help is greatly appreciated - Thanks Much. -P <% PriceArray = Recordset1("TotalBidPrice") %> <% for x = 0 to ubound(PriceArray,2) CountArray = CountArray + PriceArray(0,x) next ThePriceAvg = CountArray/(ubound(PriceArray,2) + 1) %> <%=ThePriceAvg%> |
|
#2
|
|||
|
|||
|
Recordsets in ADO are objects, not arrays. The recordset object has a recordcount property that may work for you, or you can iterate through the recordset in a do loop using movefirst, movenext.
Or you can create an array from a recordset object using the GetRows method. Refer to the ADO documentation at http://msdn.microsoft.com/library |
|
#3
|
|||
|
|||
|
Doug G
Thanks much for the info. I used recordcount and it worked great. Basically, I used recordcount to total the number of records returned by the query then used a while loop to search through the recordset to find zero values in any of the fields. I create a variable to count the zero value fields and substracted that number from the recordcount number to get by number for division. I then used that number to find the mean number totaled in that column. Just what I was looking for. Thanks for the insight! PJP |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Getting The Avg Number from a Recordset? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|