问题
I am facing difficulties in connecting PHP with SQL SERVER 2008 running on a remote computer. I have php version 5.4.3 and apache 2.2.22. I already have SQL SERVER 2008 running on my computer. I have following files included in my wamp\bin\php\php5.4.3\ext folder:
- php_sqlsrv_54_ts.dll
- php_pdo_sqlsrv_54_ts.dll
On running simple code like
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn )
{
echo "Connection established.\n";
}
else
{
echo "Connection could not be established.\n";
die( print_r( sqlsrv_errors(), true));
}
I am getting following error:
Connection could not be established. Array (
[0] => Array (
[0] => IMSSP [SQLSTATE] => IMSSP
[1] => -49 [code] => -49
[2] => This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712
)
[1] => Array (
[0] => IM002 [SQLSTATE] => IM002
[1] => 0 [code] => 0
[2] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
)
)
But I dont know why I am being asked for Microsoft SQL Server 2012 Native Client installation.
phpI have tried this link but with no success.
Thanks in Advance.
UPDATE 1:
I downloaded php 5.3.1 and followed this tutorial and scripts works like a charm.
回答1:
According to requirements: The SQLSRV extension requires that the Microsoft SQL Server 2012 Native Client be Installed on the same Computer that is running PHP.
回答2:
Install ODBC Driver(https://www.microsoft.com/en-us/download/details.aspx?id=36434). Now I can Access the remote MSSQL Server without installing the MSSQL Server in my computer
来源:https://stackoverflow.com/questions/13305242/sqlsrv-connect-data-source-name-not-found-and-no-default-driver-specified