Groups | Blog | Home
all groups > inetserver asp general > november 2003 >

inetserver asp general : quick one--how do I know how many rows returned?


middletree
11/26/2003 4:37:41 PM
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.

middletree
11/26/2003 5:01:28 PM
Thanks. I was missing, the 1,1 after the word connection.

thanks!



[quoted text, click to view]

Ray at <%=sLocation%
11/26/2003 5:55:24 PM
See here. http://www.aspfaq.com/2193

Ray at work

[quoted text, click to view]

Bob Barrows
11/26/2003 6:41:11 PM
[quoted text, click to view]
It sounds as if you got the wrong message from that article. The GetRows
example is the whole point of that article...

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"

middletree
11/26/2003 11:50:39 PM
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.


[quoted text, click to view]

Bob Barrows
11/27/2003 9:13:33 AM
[quoted text, click to view]
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

--
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"

TomB
11/27/2003 9:45:44 AM
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.


[quoted text, click to view]

Bob Lehmann
11/27/2003 11:03:43 AM
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

[quoted text, click to view]

dlbjr
11/27/2003 8:22:22 PM
rs.Open strSQL, Conn,adLockReadOnly,adCmdTable
intRecordCount = rs.RecordCount



-dlbjr

Discerning resolutions for the alms

AddThis Social Bookmark Button