Link to home
Start Free TrialLog in
Avatar of RICHARDH
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.
   

Avatar of Marcus Bointon
Marcus Bointon
Flag of France image

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.
Avatar of RICHARDH
RICHARDH

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
ASKER CERTIFIED SOLUTION
Avatar of Marcus Bointon
Marcus Bointon
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial