Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 counting records...
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Spoon
Average Member

Ireland
507 Posts

Posted - 16 July 2001 :  14:25:51  Show Profile  Visit Spoon's Homepage  Send Spoon an ICQ Message
Hi all,

In my address book, you can search differnt fields, such as name, phone, email etc.

But i was wondering is there any way you can count the amount of records that match your search.

I dont suppose the .recordcount works for it???

Thanks in advance


Regards,

Spoon, (ya all love me right?)

gor
Retired Admin

Netherlands
5511 Posts

Posted - 16 July 2001 :  14:40:09  Show Profile  Visit gor's Homepage
You can use the RecordCount property on recordsets to have it return the number of records.
If the cursor type is set to either KeySet or Static recordset, the count will be accurate. If the cursor type is set to ForwardOnly or Dynamic it will return -1
It may also return -1 if the databaseprovider does not support the functionality (don't think the ODBC driver for MySql does support it).
If you set the CursorLocation of the recordset to Clientside the recordcount will return a recordcount with all 4 the cursortypes.

Try something like this:

<%
Dim objRec
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.CursorLocation = 3 ' (try setting it to 2 to see the difference !)
objRec.Open "Select * from MyTable", My_Conn
Response.Write "RecordCount = " & objRec.RecordCount
%>


Pierre
Join the Snitz WebRing
Go to Top of Page

Spoon
Average Member

Ireland
507 Posts

Posted - 17 July 2001 :  07:11:48  Show Profile  Visit Spoon's Homepage  Send Spoon an ICQ Message
quote:

You can use the RecordCount property on recordsets to have it return the number of records.
If the cursor type is set to either KeySet or Static recordset, the count will be accurate. If the cursor type is set to ForwardOnly or Dynamic it will return -1
It may also return -1 if the databaseprovider does not support the functionality (don't think the ODBC driver for MySql does support it).
If you set the CursorLocation of the recordset to Clientside the recordcount will return a recordcount with all 4 the cursortypes.

Try something like this:


Thanks Gor, works a treat, :)

<%
Dim objRec
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.CursorLocation = 3 ' (try setting it to 2 to see the difference !)
objRec.Open "Select * from MyTable", My_Conn
Response.Write "RecordCount = " & objRec.RecordCount
%>


Pierre
Join the Snitz WebRing



Thanks GOR, it works a treat :)

Regards,

Spoon, (ya all love me right?)

Edited by - spoon on 17 July 2001 07:12:43
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.27 seconds. Powered By: Snitz Forums 2000 Version 3.4.07