PDO MSSQL DEMO

<?php

try {  
	$hostname='117.79.93.222';
	$port=1433;//端口  
	$dbname="csdn";//库名  
	$username="csdn_admin";//用户  
	$pw="123456";//密码  
	$dbh= new PDO("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");  

} catch (PDOException $e) { 
	echo"Failed to get DB handle: ".$e->getMessage() ."n";  
	exit; 
} 
echo'connent MSSQL succeed';  
$stmt=$dbh->prepare("SELECT * FROM  CSDNUser");  
$stmt->execute(); 
while ($row=$stmt->fetch()) { 
	print_r($row);  
} 
unset($dbh); 
unset($stmt);

你可能感兴趣的:(PDO MSSQL DEMO)