0

我正在尝试将我的 PHP 与 SQL Server 连接起来。我必须去现场测试它,所以我正在为笔记本电脑配置必要的设置。在我目前工作的桌面上,连接工作正常。但在笔记本电脑中,它不会连接。这是我正在使用的代码:

$serverName = "server"; //serverName\instanceName

$connectionInfo = array( "Database"=>"DB", "UID"=>"user", "PWD"=>"pass");
$conn = sqlsrv_connect($serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}

我已将 .dlls 放在 ext 文件中,并在 php.ini 中编写了扩展名,但不知何故它仍然无法正常工作。这是我得到的错误:

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

任何帮助将不胜感激。谢谢你。

4

2 回答 2

1

http://www.microsoft.com/en-us/download/details.aspx?id=29065#SNAC

这就是答案。我下载了 Microsoft® SQL Server® 2012 Native Client,一切都很顺利。我搜索了这个链接的高低,所以现在我在这里分享它,希望能帮助任何像我一样正在寻找它的人。

于 2013-03-07T17:56:58.763 回答
0

@plasmy,谢谢。我也到处搜索以使其正常工作。页面顶部的下载链接为您提供了一个文本文件,其中包含有关如何下载文件的说明,这真的是 wtf。本机客户端的直接链接在这里:

http://go.microsoft.com/fwlink/?LinkID=239648&clcid=0x409

于 2013-06-19T14:05:11.183 回答