//Author:erquan
//Date:2003-3-4
//City:郑州
$dbConn=new COM ("ADODB.Connection") or die("创建COM失败");
$ADO="Provider=sqloledb;Data Source=localhost;Initial Catalog=myTest;User Id=sa;Password=sa;";
//Access如:$ADO="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("mydb.mdb");
$dbConn->open($ADO);
//if($dbConn) echo"create conn OK";
$rs=new COM("ADODB.RecordSet") or die("创建RS失败");
echo"
";
//if($rs) echo"create rs OK";
$sql="SELECT * FROM tb_bs";
$rs->open($sql,$dbConn,1,1);
while(!$rs->eof){
echo $rs->fields["i_BsID"]->value.":";
echo $rs->fields["vc_BsName"]->value;
echo"
";
$rs->movenext();
}
$rs->Close;
$rs=null;
$dbConn->Close;
$dbConn=null;
?>
怎么样,很简单吧?对于ASP Coder,万一突然你的BOSS接到一个PHP项目的单子,你也不必惊慌,花一点时候你也可以顺利地进行开发了~
访问SQLServer的存储过程,也和ASP的做法几乎一样。