1

我在将 PHP 与在远程计算机上运行的 SQL SERVER 2008 连接时遇到了困难。我有 php 版本 5.4.3 和 apache 2.2.22。我的计算机上已经运行了 SQL SERVER 2008。我的 wamp\bin\php\php5.4.3\ext 文件夹中包含以下文件:

  • php_sqlsrv_54_ts.dll
  • php_pdo_sqlsrv_54_ts.dll

在运行简单的代码时

$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));
}

我收到以下错误:

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
    )
) 

但我不知道为什么我被要求安装Microsoft SQL Server 2012 Native Client

php我试过这个链接但没有成功。

提前致谢。

更新 1:

我下载了 php 5.3.1 并按照本教程操作,脚本就像一个魅力。

4

2 回答 2

2

根据要求:SQLSRV 扩展要求 Microsoft SQL Server 2012 Native Client 安装在运行 PHP 的同一台计算机上。

于 2012-11-09T09:27:44.670 回答
0

安装 ODBC 驱动程序(https://www.microsoft.com/en-us/download/details.aspx?id=36434)。现在我可以 访问远程 MSSQL Server,而无需在我的计算机中安装 MSSQL Server

于 2016-05-04T11:00:19.567 回答