0

我使用 unixODBC 通过 odbc 连接到 mssql 数据库。问题是无论我在 odbc.ini 中添加多少数据源,它总是使用列表中的第一个数据库。

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

我的代码:

@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']);
4

1 回答 1

0

有了那个 odbcinst,ini 我会尝试

$dns="驱动程序={SQLSERVER};服务器={$dbhost};数据库={$connInfo['Database']};";

或者

$dns="DSN=INTERPOLICY";

于 2013-02-07T11:00:43.483 回答