| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
RecordCount - How to get a RecordCount from a RecordSet
Why does RecordCount return as -1?
Recordcount is not supported with the default forward-only cursor asp Code:
Below are five methods to get the correct RecordCount Note: Where the RecordCount is displayed above/before the Recordset
__________________
CyberTechHelp |
|
#2
|
|||||
|
|||||
|
Count()
You can use the SQL Count() function to get a RecordCount
In this example a second RecordSet is used to execute the query using the Count() function. asp Code:
|
|
#3
|
|||||
|
|||||
|
CursorType
You can change the CursorType of the RecordSet to get the RecordCount
http://www.w3schools.com/ado/met_rs_open.asp Code:
objRecordset.Open source,actconn,cursortyp,locktyp,opt Note: You also need to specify the LockType when specifying the CursorType. The default CursorType is 0 (adOpenForwardOnly) The default LockType is 1 (adLockReadOnly) asp Code:
|
|
#4
|
|||||
|
|||||
|
Loop and MoveFirst
You can Loop through the RecordSet and increment a variable to hold the RecordCount.
Here is an example using a While loop and MoveFirst to reset the RecordSet asp Code:
Last edited by degsy : April 19th, 2007 at 07:20 AM. |
|
#5
|
|||||
|
|||||
|
Loop through and concatenate string to create variable
You can Loop through the Recordset and create two variables.
One will hold the RecordSet data The other will increment a counter for the RecordCount asp Code:
|
|
#6
|
|||||
|
|||||
|
getRows()
You can use getRows() to put the contents of the RecordSet into an array.
You can then use the UBound function to get the RecordCount. You can then use a For Loop to loop through the RecordSet asp Code:
|
|
#7
|
||||
|
||||
|
nice work Degsy
![]()
__________________
Look! Its a ShemZilla ![]() ![]()
|