全部博文(921)
分类:
2007-11-14 14:55:18
$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);
}