PHP:連線MS-SQL資料庫

$server = "myPC\SQLEXPRESS";
$database = 'User';
$user = 'sa';
$password = '1234';

//透過ODBC連線到MS-SQL
$conn = odbc_connect("Driver={SQL Server};Server=$server;Database=$database;", $user, $password);

//透過Microsoft SQL Server Functions (PDO_SQLSRV)連線到MS-SQL
try {
	$dbh = new PDO("sqlsrv:Server=$server;Database=$database", $user, $password);
} catch (PDOException $e) {
    echo "Failed to get DB handle: " . $e->getMessage() . "\n";
    exit;
}
本篇發表於 MSSQL, PHP。將永久鏈結加入書籤。

回應已關閉。