Benjamin
Benjamin

Reputation: 617

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.

Upvotes: 2

Views: 2562

Answers (1)

Garry M. Biggs
Garry M. Biggs

Reputation: 21

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

Upvotes: 2

Related Questions