|
 |
access_asp thread: Count with access
Message #1 by ste4u.couk@b... on Wed, 11 Dec 2002 13:23:58
|
|
I wish to perform a search of my access BD. How can I tell how many
results have been found?
I?m using (?ADODB.Recordset?) with a SQL statement.
Can I use :
SELECT COUNT(*) FROM Persons WHERE Age>20
And if so how do I put the result in to a string.
Regards
Steven
Message #2 by "Carl E. Olsen" <carl-olsen@m...> on Wed, 11 Dec 2002 07:36:26 -0600
|
|
Do the record set thing:
Dim oRS
Set oRS = Server.CreateObject("ADODB.Recordset")
oRS.Open "SELECT * FROM Persons WHERE Age > 20"
Dim aVariable
aVariable = oRS.RecordCount
That should do it. If it returns as an integer instead of string, you
can convert it. I think its CStr(aVariable), but I can't remember off
the top of my head.
Carl Olsen
> -----Original Message-----
> From: ste4u.couk@b... [mailto:ste4u.couk@b...]
> Sent: Wednesday, December 11, 2002 1:24 PM
> To: Access ASP
> Subject: [access_asp] Count with access
>
> I wish to perform a search of my access BD. How can I tell how many
> results have been found?
> I'm using ("ADODB.Recordset") with a SQL statement.
> Can I use :
> SELECT COUNT(*) FROM Persons WHERE Age>20
> And if so how do I put the result in to a string.
> Regards
> Steven
>
>
> to unsubscribe send a blank email to leave-access_asp-
> 1112135Q@p...
Message #3 by "Ken Schaefer" <ken@a...> on Thu, 12 Dec 2002 12:59:46 +1100
|
|
<%
strSQL = _
"SELECT COUNT(*) AS NumberOfPeople FROM Persons WHERE Age > 20"
intCount = objConn.Execute(strSQL,,adCmdText).Fields("NumberOfPeople").Value
%>
(or you can do it the longer way:
<%
...
Set objRS = objConn.Execute strSQL,,adCmdText
intCount = objRS("NumberOfPeople")
%>
DON'T USE .RecordCount - IT IS VERY, VERY SLOW!!
www.adopenstatic.com/faq/recordcountalternatives.asp
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <ste4u.couk@b...>
Subject: [access_asp] Count with access
: I wish to perform a search of my access BD. How can I tell how many
: results have been found?
: I?m using (?ADODB.Recordset?) with a SQL statement.
: Can I use :
: SELECT COUNT(*) FROM Persons WHERE Age>20
: And if so how do I put the result in to a string.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
 |