Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Can multi queries be done in ASP pages?

Reply
Thread Tools

Can multi queries be done in ASP pages?

 
 
Lord Merlin
Guest
Posts: n/a
 
      05-10-2004
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).


 
Reply With Quote
 
 
 
 
William Morris
Guest
Posts: n/a
 
      05-10-2004
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:(E-Mail Removed)...
> 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).
>
>



 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      05-10-2004
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.


 
Reply With Quote
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      05-10-2004
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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tracing SQL queries done via DBI (mod_perl) Ignoramus8495 Perl Misc 6 04-26-2006 09:46 PM
xslt queries in xml to SQL queries Ian Roddis Python 3 02-26-2006 06:49 PM
I asked before and was told it could not be done, well its Done...?? Karen Parker NZ Computing 32 08-27-2004 07:21 AM
I asked before and was told it could not be done, well its Done...?? Karen Parker NZ Computing 7 08-26-2004 02:25 AM
so many queries within queries I'm confused Abby Lee ASP General 11 08-06-2004 07:56 PM



Advertisments