RICHARDH
asked on
ODBC Multiple Database connections
HI,
I have executed a query to an odbc souce and within this query I am trying to loop another query to the same database but looking at different tables but it errors when it tries to use the second query.
I am using a different connection as shown below, but it will not work.
$connect = odbc_connect("FreeTDS", "odbcadm", "");
Perform Query
Loop
$connect2 = odbc_connect("FreeTDS", "odbcadm", "");
Perform second query
odbc_close($connect2);
End the loop
The second query never gets executed and errors occur as the first result set appears to be lost
Thanks for any help.
I have executed a query to an odbc souce and within this query I am trying to loop another query to the same database but looking at different tables but it errors when it tries to use the second query.
I am using a different connection as shown below, but it will not work.
$connect = odbc_connect("FreeTDS", "odbcadm", "");
Perform Query
Loop
$connect2 = odbc_connect("FreeTDS", "odbcadm", "");
Perform second query
odbc_close($connect2);
End the loop
The second query never gets executed and errors occur as the first result set appears to be lost
Thanks for any help.
You don't need to open a second connection to execute a second query. just issue a second query and you'll get a second result set, which shouldn't interfere with your first one. The only time I've needed multiple connections is when I want to post updates about a transaction that has not yet committed in another connection.
ASKER
HI,
Thanks for that but I am afraid that does not work either, I had tried that first as that seemed the logical approach. As soon as I try to create the second query I get the result shown below\:
Warning: odbc_exec() [function.odbc-exec]: SQL error: , SQL state p*(p*( in SQLExecDirect
Thanks for the help.
Regards
Richard
Thanks for that but I am afraid that does not work either, I had tried that first as that seemed the logical approach. As soon as I try to create the second query I get the result shown below\:
Warning: odbc_exec() [function.odbc-exec]: SQL error: , SQL state p*(p*( in SQLExecDirect
Thanks for the help.
Regards
Richard
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.