quick one--how do I know how many rows returned?

M

middletree

When I do a query that I know has 2 rows, I get rs.recordcount equals -1.
Same thing when it's just one row. I need something that gives me the number
of rows.
 
B

Bob Barrows

middletree said:
Thanks. I was missing, the 1,1 after the word connection.
It sounds as if you got the wrong message from that article. The GetRows
example is the whole point of that article...

Bob Barrows
 
M

middletree

Well, the GetRows thing seemed to be more efficient, according to the
article, but other than that, I couldn't see any advantage. By adding 1,1, I
was able to get my problem solved much quicker than putting new code in,
even though it would have only been a few rows. And since any performance
improvement from using GetRows would not be likely to be noticed on an app
that has 6-8 users, no reason to bother.
 
B

Bob Barrows

middletree said:
Well, the GetRows thing seemed to be more efficient, according to the
article, but other than that, I couldn't see any advantage. By adding
1,1, I was able to get my problem solved much quicker than putting
new code in, even though it would have only been a few rows. And
since any performance improvement from using GetRows would not be
likely to be noticed on an app that has 6-8 users, no reason to
bother.
Are other apps running on that web server? Is this app the only one that
uses that database server as a backend? Is yours the only application
running on your network?

You can't keep thinking in terms of how something will affect the current
application. You are not creating a desktop appplication.

By adding 1,1, you told ADO to open a more expensive cursor. Expensive in
terms of memory used, CPU used to build it, network traffic used to populate
it, database server resources used to build it, etc. Now if this application
was the only application running on yor web server, network, and database
server, then sure: go ahead and allow your application to be a resource hog.
But, if you have other applications on that server, and they are all built
with your thinking in mind, do not be surprised when your server starts
running out of resources.

Opening a scrollable cursor, merely to allow you to use RecordCount, is
incredibly wasteful, especially when a much more efficient alternative
exists ...

Bob Barrows
 
T

TomB

Further to Bob's comments.
Spending that couple of minutes knowing how to use GetRows properly and
optimizing your code, will allow you to re-use your code when your boss
walks in and tells you that your site is now going to be used for 6-8
bazillion users.

Also, when you are asked to do a bigger job; you'll have the knowledge and
confidence to do it. Then your boss will give you a huge bonus and you can
retire.
 
B

Bob Lehmann

Sometimes it is quicker to grab a table knife to tighten a screw. It might
work, but that doesn't mean it was the right thing to do.

Bob Lehmann
 
D

dlbjr

rs.Open strSQL, Conn,adLockReadOnly,adCmdTable
intRecordCount = rs.RecordCount



-dlbjr

Discerning resolutions for the alms
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top