日期:2014-05-16 浏览次数:20453 次
$conn=new COM("ADODB.Connection"); $dsn="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=".realpath("data.mdb").";Uid=Admin; Pwd=BDC2002Data;"; $conn->open($dsn); $sql="select * from dict"; $rs=$conn->Execute($sql); $row="0"; while(!$rs->EOF) { for ($i=0;$i<$rs->Fields->count;$i++) { if ($i==0) { $string.=$rs->Fields($i)->Value; continue; } $string.='|'.$rs->Fields($i)->Value; } $string.="\n"; if ($row==300) { //break; } $row++; $rs->MoveNext(); echo $string; } 或者 //ODBC连接数据库 $cnx=odbc_connect("program","",""); if(!$cnx){ error_handler("ODBC_connect连接有错误",$cnx); } $cur=odbc_exec($cnx,"select * from diary"); if (!$cur){ error_hander("Odbc_exec运行有错,没有指针传回",$cur); } //取出成功的数据 $cur=odbc_exec($cnx,"select * from diary order by id desc"); while(odbc_fetch_row($cur)) { $title=odbc_result($cur,2); $id=odbc_result($cur,1); $content=odbc_result($cur,4); $date=odbc_result($cur,5); $images=odbc_result($cur,3); } <?php $connstr="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("data.mdb"); $connid=odbc_connect($connstr,"","",SQL_CUR_USE_ODBC); $issuetime=date("Y-m-d H:i:s"); $sql="insert into test values("","",...)"; $result=odbc_exec($connid,$sql); if($result) echo "successful"; else echo "failed"; ?>?