Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Counting Values in a Recordset
Message
De
31/03/2001 11:24:20
 
 
À
28/03/2001 10:17:09
Todd Wolfe
Certified Marketing Services
Kinderhook, New York, États-Unis
Information générale
Forum:
Internet
Catégorie:
Active Server Page
Divers
Thread ID:
00489424
Message ID:
00490602
Vues:
10
Hi Todd, here is a solution:
Dim rsForCount, cnnExisting
Set rsForCount = Server.CreateObject( "ADODB.Recordset")
' we will use your existing connection
Set cnnExisting = rsYourExistingRecorset.ActiveConnection
rsForCount.CursorLocation = 3                ' adUseClient, to be able to disconnect recorset
rsForCount.Open "Select COUNT(*) As Count From TableName Where WhereClause", cnnExisting
Set rsForCount.ActiveConnection = Nothing    ' get a disconnected recordset
myField = rsForCount.Fields( "Count").Value
Set rsForCount = Nothing
The same thing you may use to SUM field values and so on.

With best regards,
Alex


>With fox pro working with tables allows the utilization of a count statement to found out how many of something ='s a certain value. Such as this statment
>
>count for myfield='X' to m.myfield
>
>I am working with ASP currently and connecting to fox pro table using odbc. Is there a way to count a field name = to a certain value like above in my recordset created with ADO? I am going to have several fields that need totaing in my recordset and I would prefer not to use a loop for efficiency purposes.
>
>
>Thanks in advace.
Alex
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform