简体   繁体   English

已安装SQLSRV驱动程序,但使用PHP连接到MSSQL 2008 R2数据库时显示错误

[英]SQLSRV driver installed but shows error while connecting to MSSQL 2008 R2 db using PHP

I have a laptop running with windows 7 Professional, MSSQL 2008 R2 and IIS 7.5. 我有一台运行Windows 7 Professional,MSSQL 2008 R2和IIS 7.5的笔记本电脑。 The system has all my applications in c# and php running successfully. 系统在c#和php中成功运行了我的所有应用程序。 Now I wanted to transfer all my files and apps on a 2nd laptop with windows 7 Ultimate. 现在,我想在装有Windows 7 Ultimate的第二台笔记本电脑上传输所有文件和应用程序。 But for some reason I just cannot get a successful connection to my db even though phpinfo() shows sqlsrv installed and I am using the exact same code just changing the connection string of the DB. 但是由于某种原因,即使phpinfo() 显示已安装sqlsrv ,我也无法成功连接到数据库,并且我使用的是完全相同的代码,只是更改了数据库的连接字符串。

I have MSSQL management Studio v 10.50.2500 我有MSSQL Management Studio v 10.50.2500
IIS v 7.5.7600.16385 IIS v 7.5.7600.16385
PHP v 5.5.3 PHP v 5.5.3
SQLSRV Driver for php 5.5 (its not an official MS release , but its quite popular and works on my previous laptop ) 适用于php 5.5的SQLSRV驱动程序(它不是正式的MS版本,但非常流行,并且可以在我以前的笔记本电脑上使用)

I am getting an error like : 我收到类似这样的错误:


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

my PHP code is as follows (which i know for a fact it works on the first laptop) : 我的PHP代码如下(我知道它可以在第一台笔记本电脑上工作):


    `$serverName = "DELL-PC"; //serverName\instanceName`
    ``
    `$connectionInfo = array( "Database"=>"amlTest");`
    `$conn = sqlsrv_connect( $serverName, $connectionInfo);`

I just cannot figure out what is the problem or where am I missing out? 我只是无法弄清楚问题出在哪里,或者我在哪里错过了? I really need this working!! 我真的需要这个工作! and have spent far too much time re-installing all my softwares and trying out all php versions. 并且花了太多时间重新安装我的所有软件并尝试所有php版本。
I hope its not because of the difference in windows version 我希望不是因为Windows版本的差异

Also, Sorry if I have made any mistake formatting my question, as this is my first post. 另外,对不起,如果我在设置问题格式时遇到任何错误,因为这是我的第一篇文章。

Have you installed the feature pack? 您是否安装了功能包?

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

A hint from the error tells us that you need the 2012 version of the MS SQL Server for this to work. 错误提示告诉我们,您需要2012版的MS SQL Server才能正常工作。 Also make sure your Server permissions are set correctly. 另外,请确保正确设置服务器权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM