Recordset!

A

Arpan

Assume that an ASP page has 3 SQL queries. Can a recordset object be
populated with the records of all these 3 queries at the same time?

Please note that the 3 queries are distinct queries, not related to
each other in any way. Also please note that I am not talking about
populating the recordset with the records of the 1st query, then
closing it & again opening that recordset, populating it with the
records of the 2nd query so on & so forth.

Thanks,

Arpan
 
B

Bullschmidt

Sure if all the fields are of exactly the same type in each part.

Union
http://www.w3schools.com/sql/sql_union.asp

Best regards,
J. Paul Schmidt, Freelance Web and Database Developer
http://www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips

<<
Assume that an ASP page has 3 SQL queries. Can a recordset object be
populated with the records of all these 3 queries at the same time?

Please note that the 3 queries are distinct queries, not related to each
other in any way. Also please note that I am not talking about
populating the recordset with the records of the 1st query, then closing
it & again opening that recordset, populating it with the records of the
2nd query so on & so forth.
 
R

Ray Costanzo [MVP]

Not really.* Are they coming from the same database? You could union the
queries on the database server.

Ray at work

* Yes, actually you can if you really want to, but why on Earth...?
 
P

Prabhat

Arpan said:
Assume that an ASP page has 3 SQL queries. Can a recordset object be
populated with the records of all these 3 queries at the same time?

Please note that the 3 queries are distinct queries, not related to
each other in any way. Also please note that I am not talking about
populating the recordset with the records of the 1st query, then
closing it & again opening that recordset, populating it with the
records of the 2nd query so on & so forth.

Thanks,

Arpan

Hi Arpan,

I think you have 3 Different SQL Query and dont want to use 3 recordset but
you want to open / populate ONLY ONE recordset that consistes of all 3 SQL
Query?

If that is the case then use NextRecordset method of ADO. Let me know if
this help.

Thanks
Prabhat
 
B

Bob Barrows [MVP]

Prabhat said:
Hi Arpan,

I think you have 3 Different SQL Query and dont want to use 3
recordset but you want to open / populate ONLY ONE recordset that
consistes of all 3 SQL Query?

If that is the case then use NextRecordset method of ADO. Let me know
if this help.
THis will not work with Access, which does not support batch queries. Of
course, since we don't know what database is being used ...

Arpan, please. Always specify the database type and version you are using in
EVERYdatabase-related post you make. Do not assume that we will know your
database by your previous posts:
a) we may not have read your previous posts
b) you may be using a database that is different from the one used in your
previous posts

You will avoid receiving unusable replies if you remember to do this. Make
it a header that you copy/paste into each of your questions to the group.

As Ray mentioned, it may be possible to construct a union query that will
retrieve your results in a single recordset. However, this will only work if
the queries are all being run in the same database (Access) or on the same
server (SQL Server)
 
D

Danny@Kendal

Arpan said:
Assume that an ASP page has 3 SQL queries. Can a recordset object be
populated with the records of all these 3 queries at the same time?

Please note that the 3 queries are distinct queries, not related to
each other in any way. Also please note that I am not talking about
populating the recordset with the records of the 1st query, then
closing it & again opening that recordset, populating it with the
records of the 2nd query so on & so forth.

I have three tables for a What's On database - Dates, Classes and Hosts.
It's a MS Access database and I use ASP with VBScript to generate results
for a web page.

Dates is a table of dates with a link to Classes via ClassID.
Classes contains details of the event with a link to Hosts via HostName.
Hosts contains details of who is hosting the event.

If a date is listed then there must be a corresponding event set up. Not
every event has a host. I use the following SQL query to dump results into a
single recordset. I'm no expert so make of it what you will. All polite
criticism appreciated. :)

SELECT *
FROM Hosts
RIGHT JOIN
(Classes INNER JOIN Dates ON Classes.ClassID=Dates.ClassID)
ON Hosts.HostName=Classes.HostName
WHERE (add your filters here)
AND (add another filter here if you like)
ORDER BY (sort the results)
 
P

Prabhat

Bob Barrows said:
THis will not work with Access, which does not support batch queries. Of
course, since we don't know what database is being used ...

Arpan, please. Always specify the database type and version you are using in
EVERYdatabase-related post you make. Do not assume that we will know your
database by your previous posts:
a) we may not have read your previous posts
b) you may be using a database that is different from the one used in your
previous posts

You will avoid receiving unusable replies if you remember to do this. Make
it a header that you copy/paste into each of your questions to the group.

As Ray mentioned, it may be possible to construct a union query that will
retrieve your results in a single recordset. However, this will only work if
the queries are all being run in the same database (Access) or on the same
server (SQL Server)


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

Yes that will not work on MS Access.
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top