0

I use unixODBC to connect to mssql databases via odbc. The problem is that regardless how many data sources I add in odbc.ini, it always uses the first database in the list..

odbcinst.ini
[ODBC]
Trace           = Yes
TraceFile       = /tmp/sql.log
ForceTrace      = Yes
Pooling         = Yes
[SQLSERVER]
Description     = SQLSERVER
Driver          = /usr/local/freetds/lib/libtdsodbc.so
Setup           = /usr/local/freetds/lib/libtds.so
CPTimeout       = 5
CPReuse         = 5
#FileUsage       = 1

odbc.ini
[DNS1]
Driver          = SQLSERVER
Description     = SQLSERVER
Server          = 192.168.1.10
Database        = fr_boatsdata
Port            = 2300
[INTERPOLICY]
Driver          = SQLSERVER
Description     = SQLSERVER
Server          = 192.168.1.10
#Database       = inter_policy
Port            = 2300

My code:

@include(S_ROOT.'./source/lib/adodb5/adodb.inc.php');
$this->link = &ADONewConnection('odbc_mssql');
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$dns="Driver={SQL Server};Server={$dbhost};Database={$connInfo['Database']};";
//$dns="DNS=INTERPOLICY";
@$this->link->Connect($dsn,$connInfo['UID'],$connInfo['PWD']);

1 Answers1

0

With that odbcinst,ini I would try

$dns="Driver={SQLSERVER};Server={$dbhost};Database={$connInfo['Database']};";

Or

$dns="DSN=INTERPOLICY";

Nick Gorham
  • 1,118
  • 8
  • 9