Here's how I'm setting up the code. I've tried two differrent ways:
set rs=server.creatobject("adodb.recordset")
Const adOpenStatic=0
with rs
.cursortype=adOpenStatic
end with
rs.open sql, cn
myCount=rs.recordcount
I've also tried
rs.open sql, cn, adOpenStatic
myCount=rs.recordcount
Both of these return a -1 result, no matter how many rows there are in
the recordset. I'm at my wits end here. What do I do?
Thanks,
Bill
Ray at work
"Bill" <billzi...@gospellight.com> wrote in message
news:8da5f4f4.03062...@posting.google.com...
If I was doing it, I would not open a more expensive cursor just to get the
record count. I would open the recordset using execute, and use GetRows to
read the data from the recordset into an array, like this:
ar = rs.GetRows
This allows me to immediately close the recordset and connection, thus
improving the performance and scalability of my application. It can be
thousands of times faster to loop through an array than through a recordset.
And the bonus: to get the recordcount, just do:
lRecs = ubound(ar,2)
I have posted several examples of using GetRows in the past couple months:
it shouldn't be too hard to use Google to find them.
Bob Barrows
Bill
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
set rs=server.creatobject("adodb.recordset")
rs.open sql, cn, 3
myCount=rs.recordcount
if you still get -1 then the problem is your sql is not finding any matching
records.
look here for more info.:
http://www.aspin.com/func/search?cob=aspkey&qry=recordcount
================================
http://www.ASPkey.net/
A Resource Site for Web Developers
*Free OnLine web Tools
*Free development services
================================
Bill wrote in message <8da5f4f4.03062...@posting.google.com>...
Plus 1?
http://forums.devshed.com/t48403/s06a710d314edaca56e70c78a0275251f.html
SPA
"Bill" <billzi...@gospellight.com> wrote in message
news:8da5f4f4.03062...@posting.google.com...
Now I'm really off-base - good catch
The problem is this:
Const adOpenStatic=0
The value for adOpenStatic is 3, not 0. See here:
http://www.connectionstrings.com/adoenumerations.asp
See here for an alternative to using Const:
http://www.aspfaq.com/show.asp?id=2112
I still think you should consider using GetRows.
Bob Barrows
LOL. By the way, I owe you a debt of thanks. I've recently started to adopt
your sp as connection method philosophy and I really like it. I paid for the
connection object, why not take advantage of everything it has to offer,
right? Thanks.
-Chris
But, you're welcome :-)
Bob
PS. Again, this technique is broken in dotnet, so keep that in mind ...