Chris Barber wrote:
Default cursor type is 'firehose' forward-only server-side which
doesn't populate the recordcount property.
Try doing:
.MoveLast
.MoveFirst
to populate the recordcount
There are some problems with this advice:
1. Since it's a forward-only cursor, the MoveFirst method will usually not
be supported. Some providers, however, will support it, but their method of
supporting it may not be to your liking: MoveFirst causes the recordset to
be requeried, which can have a large impact on performance. If the provider
does not support MoveFirst with forward-only cursors, and error will be
raised.
2. Even if the MoveFirst is supported, it will still be a forward-only
cursor, and RecordCount will still contain -1 after the MoverFirst. This is
different from the behavior of DAO recordsets.
or consider a client-side cursor (all
data gets transferred to the client).
That will definitely work. However, you do not need a client-side cursor to
get a recordcount: there are several server-side cursor types that will
support record-count: static, keyset, dynamic, and with the Jet provider,
Table.
However, I do not recommend opening one of the non-default cursor types
merely to get a record count. The non-default cursor types require more
resources and do not perform as well as the default due to the extra
functionality offered. There are other ways to get a record count from a
default forward-only cursor. My favorite is to use GetRows to stuff the data
from the recordset into an array. This has two benefits:
1. I can immediately close the recordset and connection, allowing other
threads on the server to use the connection instead of creating a new one.
2. I can work with the data in the array, which will be much quicker than
using a cursor to work with it.
Once the data is in the array, you can use Ubound to determine the number of
records:
est.Open ...
if not est.EOF then arResults = est.GetRows
est.close: set est = nothing
objConn.close:set objConn=nothing
if isArray(arResults) then
response.write Ubound(arResults,2) & " records"
else
response.write "no records"
end if
HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"