Print Page | Close Window

Open Multiple SQLs

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=5097
Printed Date: 30 March 2026 at 7:44pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Open Multiple SQLs
Posted By: Aumuz
Subject: Open Multiple SQLs
Date Posted: 17 August 2003 at 9:58pm

Is it possible to open multiple SQLs at one time?

Would the code be somthing like this?

<% site_record.open SQL_1, SQL_2, site_data_base %>

Easily answered question, but I don't have them time to find out right now, nore do I have the need for it right now (but by tuesday I will).

If its not possibel how do I get around it?

Like this?

<% site_record_1.open SQL_1, site_data_base %>

<% site_record_2.open SQL_2, site_data_base %>

Thanks for any help you can give me.




Replies:
Posted By: ljamal
Date Posted: 17 August 2003 at 10:23pm
it is possible to sende multiple queires with a single call via SQL, but the database you are using has to be bale to support it. SQL Server does, but Access does not. The syntax is the same as using a single SQL query except your queries need to be separated by a semi-colon (for SQL Server) and your recordset object will have multiple recordsets which you can move through using RecordSetName.NextRecordSet(). If you are using SQL Server, I highly recommend taking advantage of this as it can reduce the time taken to generate a page.

If you are using Access then you will just have to use multiple calls. If you want to use the same recordset name over and over then you can move the recordset information into an array by using
arrayName = RecordSetName.GetRows



-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: 3BEPb
Date Posted: 18 August 2003 at 1:08am

ljamal, it's funny, and I read a lot about Access cannot handle multiple queries, however I did it many times... and I have no idea why I did it, if it's impossible...

p.s. I'm using my PC for couple of years and it never freezes. Am I doing something wrong?



Posted By: ljamal
Date Posted: 18 August 2003 at 5:41am
It's not possible for Access to process multiple queries from a single SQL statement. The JET engine that Access uses to process SQL statements does not allow it. It will allow processing one SQL statement after another with separate trips to the database, but not 2 or more queries in one trip to the database. If you think you have sent multiple queries then I would love for you to post the code with the statements.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: Aumuz
Date Posted: 18 August 2003 at 6:45am
Ok, thanks...


Posted By: 3BEPb
Date Posted: 21 August 2003 at 9:51am

-- but not 2 or more queries in one trip to the database ---

ljamal, does it mean INNER JOINS won't work?



Posted By: ljamal
Date Posted: 21 August 2003 at 11:13am
An join (inner or outer) is still a single query no matter how many tables are included. With SQL server you can do this:

strSQL = "select * from table; select * from table2; select * from table3"
Set RS=Conn.Execute(strSQL)

and it will return a recordset object that contains 3 recordsets. With Access you have to call each query one at a time to get the 3 recordsets like below:

strSQL = "select * from table"
Set rs1 = Conn.execute(strSQL)

strSQL = "select * from table2"
Set rs2 = Conn.execute(strSQL)

strSQL = "select * from table3"
Set rs3 = Conn.execute(strSQL)

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: 3BEPb
Date Posted: 21 August 2003 at 1:09pm

Gotcha!

Thanks, for explanations. Everything works because I opened all recordsets separatelly.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net