This is the standard code when using Windows Authentication:
<?php
try {
$conn = new PDO("sqlsrv:Server=geoffrey-pc\SQLEXPRESS;Database=books",
NULL, NULL);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo $e;
die("Error connecting to SQL Server");
}
echo "Connected to SQL Server\n";
?>
The above works for connecting to a local server (SQL Server 2008 Express Edition), but not for connecting to a server on the network (SQL Server Standard Edition). Error message:
exception "PDOException" with the message "SQLSTATE [28000]: [Microsoft] [SQL Server Native Client 10.0] [SQL Server] Login failed for user 'myDomain \ GEOFFREY-PC $'. 'in C: \ wamp \ www \ PhpProject1 \ index.php: 10 Stack trace: # 0 C: \ wamp \ www \ PhpProject1 \ index.php (10): PDO → __ construct ('sqlsrv: Server = n ...', NULL, NULL) # 1 { main}
, , , abc0120 \SQLEXPRESS - , . , , .
Apache 2.2.11. MSDN SQLServer 2005 Windows:
, ( ) -, SQL Server .
, .
SQL Server Management Studio, Windows.