Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In ADO ecacute multiple SQL Statements 2

Status
Not open for further replies.

timhans

Programmer
Jun 24, 2009
75
Hello, say if I have multiple SQL statements say
SQL1, SQL2,SQL3 is there a perfered method of execution i.e

rs.open SQL1 & SQL2 & SQL3
or
rs.open SQL1
rs.open SQL2
rs.open SQL3
any comments or insight is appreciated, thanks
 
I think that the Source named parameter of the ADODB.Recordset.Open method can't be a multiple SQL statements ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV, I did not think so, but what do I know!
 
If what you are trying to accomplish is to have all the records from 3 different SQL statements in one recordset, you might be able to do it with one SQL statement that UNIONs the 3 SQL SELECTs together. It wouldn't be an updateable recordset, however.
 
Thanks JoeAtWork, I did not know a union would not be updateable
 
Try this code
Code:
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
Dim SqlStr As String
SqlStr = "Select Count(*) from Students ; Select Count(*) from providers ; Select count(*) from Sessions;"
rst.Open SqlStr, CurrentProject.AccessConnection
Debug.Print rst(0)
Set rst = rst.NextRecordset
Debug.Print rst(0)
Set rst = rst.NextRecordset
Debug.Print rst(0)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top