2

我在连接到 sql server 2008 数据库时遇到问题。我已经安装了 php 扩展php_sqlsrv.dll。我还安装了本机客户端 10.0。我使用的代码是:

 <?php /* Specify the server and connection string attributes. */
 $serverName = "(xxx.xx.x.xx)";

 /* Get UID and PWD from application-specific files.  */ $uid = "xxxxxx";
 $pwd = "xxxxx"; $connectionInfo = array( "UID"=>$uid,
                          "PWD"=>$pwd,
                          "Database"=>"xxxxxx");

 /* Connect using SQL Server Authentication. */ $conn = sqlsrv_connect(
 $serverName, $connectionInfo); if( $conn == false ) {
      echo "Unable to connect.</br>";
      die( print_r( sqlsrv_errors(), true)); } else {   echo "success";     }                                                                           sqlsrv_close($conn); ?>

sql server 也有一个身份验证类型:SQL SERVER AUTHENTICATION。上面的代码给出了以下错误:

Array ( 
        [0] => Array ( 
            [0] => 08001 
            [SQLSTATE] => 08001 
            [1] => 53 
            [code] => 53 
            [2] => [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [53]. 
            [message] => [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [53]. 
        ) 
        [1] => Array ( 
            [0] => HYT00 [SQLSTATE] => HYT00 
            [1] => 0 [code] => 0 
            [2] => [Microsoft][SQL Server Native Client 10.0]Login timeout expired 
            [message] => [Microsoft][SQL Server Native Client 10.0]Login timeout expired 
        ) 
        [2] => Array ( 
            [0] => 08001 [SQLSTATE] => 08001 
            [1] => 53 [code] => 53 
            [2] => [Microsoft][SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. 
            [message] => [Microsoft][SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. 
        ) 
    )

请帮忙

4

0 回答 0