开发者

Connecting to SQL Server using odbc mssql with Adodb5 on Linux / Mac

I cannot connect to a SQL server database from my Mac. Here's my PHP code:

开发者_如何转开发
$db = &ADONewConnection('odbc_mssql');
$db->debug = true;
$myDSN="DRIVER={SQL Server Native Client 10.0};SERVER=XXX.XXX.XXX.XX;PORT=1433;UID=XXXX;PWD=XXXXX;DATABASE=XXXXX;";
    $db->Connect($myDSN);

I've tried a whole bunch of different drivers (FreeTDS, SQL SERVER, SQL Server Native Client etc.) but I keep getting this error:

SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002

FYI, I've installed php5-mssql, freetds and unixODBC.

Thanks in advance for your help.


The error is trying to tell you that you do not have a "DRIVER={SQL Server Native Client 10.0};" on your machine.

This comes as no surprise since the SQL Server Native Client is only available on Windows.

What you need is a third party ODBC driver (or the like) such as the OpenLink Single-tier ODBC Driver for SQL Server

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜