$pwd, "Database"=>"test");$conn = sqlsrv_connect( $serverName, $con">
时间:2021-07-01 10:21:17 帮助过:170人阅读
$serverName = "localhost"; //数据库服务器地址
$uid = "sa"; //数据库用户名
$pwd = "66"; //数据库密码
$connectionInfo = array("UID"=>$uid, "PWD"=>$pwd, "Database"=>"test");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn == false)
{
echo "连接失败!";
die( print_r( sqlsrv_errors(), true));
}
else
{
echo "连接成功";
//执行有结果集的SQL语句
$query = sqlsrv_query($conn, "select ID,NAME from stuff");
while($row = sqlsrv_fetch_array($query))
{
echo $row[0]."-----".$row[1]."
";
}
sqlsrv_close( $conn);
}