![]() |
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). |
Re: Can multi queries be done in ASP pages?
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:XJGdnRXE55mXcQLdRVn-iQ@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). > > |
Re: Can multi queries be done in ASP pages?
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. |
Re: Can multi queries be done in ASP pages?
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]" <reb01501@NOyahoo.SPAMcom> wrote in message news:u74IuGtNEHA.2488@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. > > |
| All times are GMT. The time now is 09:36 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.