[thelist] RecordCount

Chris Blessing webguy at mail.rit.edu
Thu Mar 21 10:13:01 CST 2002

Hi Paul-

If you want to get a value for the RecordCount property, you'll need to (if
you haven't already) get the ADOVBS constants file and include it in your

1) download from here:
2) include it at the top like this: <!--#include

Now you can use these constants to open the recordset like this:

set objRS = server.createobject("adodb.recordset")
objRS.open strQuery, adOpenStatic, adLockReadOnly
theCount = objRS.RecordCount
theRecords = objRS.getRows()
set objRS = nothing

By using the getRows() method, you can close the record set immediately and
just loop through that array (theRecords).  Check it out in detail here:

Also, you may want to explicitly state which fields you're requesting in
your query, rather than using *.  Performance is the issue there, as well as
the reliability of the order in which the fields are returned.  By
explicitly stating "select table.id, table.firstname..." you will guarantee
that you get the fields you need in order, and nothing more.

HTH!  Feel free to ask more about GetRows() if you haven't used it; it's a
GREAT way to work with records.

Chris Blessing
webguy at mail.rit.edu

> Hi,
> 	I'm working on an extranet at the moment - I have several
> groups which
> contain documents - i would liek to count how many documents are contained
> in each group.
> Its an access database - the code i'm using is below - anyone
> know how I can
> do this?
> <%
> strQuery = "SELECT [tblGroupData].*, [tblGroups].* FROM
> [tblGroupData] INNER
> JOIN [tblGroups] ON [tblGroupData].[Gid] = [tblGroups].[Gid] WHERE
> [tblGroupData].[Uid] = "& Id &""
> 'response.write strQuery'
> Set objRS = objConn.Execute(strQuery)
> %>


> cheers
> paul

More information about the thelist mailing list