我試圖讓到Microsoft SQL Server 2008 Express的數據庫的連接,我收到以下錯誤:無法進行連線到SQL Server 2008 Express數據庫
Connection could not be established. Array ([0] => Array ([0] => IMSSP [SQLSTATE] => IMSSP [1] => -1 [code] => -1 [2] => Invalid option YSHSDB was passed to sqlsrv_connect. [message] => Invalid option YSHSDB was passed to sqlsrv_connect.))
我下面這個http://php.net/manual/en/function.sqlsrv-connect.php
PHP代碼:
<?php
$serverName = "SERV002\SQLEXPRESS"; //serverName\instanceName
array("Database" => "YSHDB", "UID" => "sa", "PWD" => "myPassword");
$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));
}
?>
編輯:
我得到f ixed線現在我得到這個:「連接不能建立。
Array ([0] => Array ([0] => 08001 [SQLSTATE] => 08001 [1] => -1 [code] => -1 [2] => [Microsoft][ODBC Driver 11 for SQL Server]SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. [message] => [Microsoft][ODBC Driver 11 for SQL Server]SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].) [1] => Array ([0] => HYT00 [SQLSTATE] => HYT00 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired [message] => [Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired) [2] => Array ([0] => 08001 [SQLSTATE] => 08001 [1] => -1 [code] => -1 [2] => [Microsoft][ODBC Driver 11 for SQL Server]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][ODBC Driver 11 for SQL Server]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.)
我已經檢查,以查看服務器是否允許遠程連接,它
您提供的鏈接中的文檔說使用「UID」和「PWD」,但您放入「userName」和「password」,您似乎也有倒退的參數:「UID」=>「sa」 –