469,352 Members | 2,054 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

Can multi queries be done in ASP pages?

The following statement works fine in SQL Query Analyser: SELECT count(*) as
a from NEWUSERS WHERE activated='Y'; SELECT count(*) as b from NEWUSERS
WHERE activated='N' -- It returns two values, yet when I have it in a .asp
file, it only displays the first value. Is there anyway around this, without
making two connections to the DB, and running two seperate queries?

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
Jul 19 '05 #1
3 1257
Sure. Assuming your recordset variable is "rs" then try this:

dim firstvalue, secondvalue
firstvalue = rs("a")
set rs = rs.nextRecordset
secondvalue = rs("b")
rs.close
set rs = nothing

- Wm

--
William Morris
Product Development, Seritas LLC
Kansas City, Missouri

"Lord Merlin" <SP4M_Rudi@SP4M_Bonzai.org.za_SP4M> wrote in message
news:XJ********************@is.co.za...
The following statement works fine in SQL Query Analyser: SELECT count(*) as a from NEWUSERS WHERE activated='Y'; SELECT count(*) as b from NEWUSERS
WHERE activated='N' -- It returns two values, yet when I have it in a .asp
file, it only displays the first value. Is there anyway around this, without making two connections to the DB, and running two seperate queries?

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends (John 15:13).

Jul 19 '05 #2
Lord Merlin wrote:
The following statement works fine in SQL Query Analyser: SELECT
count(*) as a from NEWUSERS WHERE activated='Y'; SELECT count(*) as b
from NEWUSERS WHERE activated='N' -- It returns two values, yet when
I have it in a .asp file, it only displays the first value. Is there
anyway around this, without making two connections to the DB, and
running two seperate queries?


Why not combine them into a single query?

SELECT activated,Count(*) from NEWUSERS
GROUP BY activated

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #3
Not that this is a deterrent from your method, but I would bet that
activated allows NULLs, so you might want to add WHERE activated IN ('Y',
'N') or WHERE activated IS NOT NULL or something along those lines. Or,
don't allow NULLs in the column in the first place. ;-)

(Otherwise, you will get three rows in your resultset.)

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:u7**************@TK2MSFTNGP10.phx.gbl...
Lord Merlin wrote:
The following statement works fine in SQL Query Analyser: SELECT
count(*) as a from NEWUSERS WHERE activated='Y'; SELECT count(*) as b
from NEWUSERS WHERE activated='N' -- It returns two values, yet when
I have it in a .asp file, it only displays the first value. Is there
anyway around this, without making two connections to the DB, and
running two seperate queries?


Why not combine them into a single query?

SELECT activated,Count(*) from NEWUSERS
GROUP BY activated

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Laphan | last post: by
reply views Thread by Leif | last post: by
6 posts views Thread by Andrew V. Romero | last post: by
reply views Thread by JeffJones176 | last post: by
6 posts views Thread by dbuchanan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.