A typical windows nightmare... I had nearly all of the info I needed, but the missing 5% was crucial.
My problems were exacerbated by the fact that I found the whole ODBC thingy a little confusing. I was also confused about whether I needed to catalog the node and database locally given that I was connecting from a remote machine.
At one point I had cataloged the node and db locally ( I.e I had db2 client installed) and the set up an ODBC DSN from the control panel to point at the db alias I just catalogued and was using that DSN in my php code! ..... What a mess, and it still didn't work
Anyway, it turned out that all I needed locally was the DB2 driver (I guess this equates to the client package) and I could then connect without a DSN or cataloguing locally using the code below...
(Note, the driver name can be found in the ODBC control panel area)
<?php
$conn=odbc_connect("Driver={IBM DB2 ODBC DRIVER - DB2COPY1};database=BPEDB;hostname=myhost;port=50000;protocol=TCPIP","myuser","mypass");
$sql="select name from BPC.PROCESS_TEMPLATE_B_T";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{
exit("Error in SQL");
}
while (odbc_fetch_row($rs))
{
$name=odbc_result($rs,"name");
print"$name<br>";
}
odbc_close($conn);
?>
No comments:
Post a Comment