簡體   English   中英

此擴展需要 Microsoft ODBC Driver 11 for SQL Server 才能與 SQL Server 通信

[英]This extension requires the Microsoft ODBC Driver 11 for SQL Server to communicate with SQL Server

已經在 Microsoft 上下載了 sqlsrv ...

在此處輸入圖像描述

在我的 phpinfo() 上

在此處輸入圖像描述

在此處輸入圖像描述

C:\wamp\bin\apache\apache2.4.9\binC:\wamp\bin\php\php5.5.12php.ini上啟用在此處輸入圖像描述

仍然有這樣的錯誤。

Failed to get DB handle: SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver 11 for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 

我的代碼是

try {
    $dbh = new PDO ("sqlsrv:Server=$host;Database=$db","$user","$pass");
  } catch (PDOException $e) {
    echo "Failed to get DB handle: " . $e->getMessage() . "\n";
    exit;
  }
  $stmt = $dbh->prepare("select top 5 from teams");
  $stmt->execute();
  while ($row = $stmt->fetch()) {
    print_r($row);
  }
  unset($dbh); unset($stmt);

除了pdo_sqlsrv擴展之外,您還需要在計算機上安裝 ODBC 11 驅動程序。

您可以在以下位置之一獲取它:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM