显示结果:
connect to MSSQL SERVER
表Test中数据为:
-------------------------------------------------------------------------
// 连接,选择数据库
//$db_host="localhost";
//$db_user="sa";
//$db_pw="";
//$db_name="Cangku";
//$db_link = mssql_connect($db_host, $db_user, $db_pw);
$db_link = mssql_connect("localhost","sa", "");
//判断是否链接成功
if(!mssql_select_db("Cangku",$db_link))
{
echo "Can not connect to MsSQL server";
exit;
}
else
{
echo "connect to MSSQL SERVER ";
echo "
";
}
// 执行 SQL 查询
//$query = 'SELECT SNAME,Sex, AGE FROM S';
$query = 'SELECT * FROM S';
$result = mssql_query($query);
//echo "
";
//echo("表S中数据为:");
//echo "姓名 性别 年龄 /n";
// 用 HTML 显示结果
//while ($row = mssql_fetch_array($result)) {
// echo "
//---------------表Test中数据---------------------------
$query1 = 'SELECT Name,Sex,AGE FROM Test';
$result1 = mssql_query($query1);
echo "
";
echo("表Test中数据为:");
echo "姓名 性别 年龄 /n";
//用 HTML 显示结果
while ($row1 = mssql_fetch_array($result1)) {
echo "
// 关闭连接
mssql_close($db_link) or die('failed closing mssql');
?>