该楼层疑似违规已被系统折叠隐藏此楼查看此楼
header("Content-type: text/html; charset=GBK");
/*数据库路径,请自己修改,否则可能运行不正常*/
$conn = @new COM("ADODB.Connection") or die("ADO连接失败!");
$connstr = "PROVIDER=Microsoft.ACE.OLEDB.12.0;Data Source=".realpath("access/access.accdb");
$conn->Open($connstr);
//创建记录集查询
$sql = "select * from pingjia";
$rs = new com("ADODB.RecordSet");
$rs->Open($sql, $conn, 1, 1);
$rs->MoveFirst();
//输出数据库字段名到表格标题
echo *
for ($i = 0; $i < $rs->Fields->count(); $i++)
{
echo *
*. $rs->fields($i)->name() . **;
}
echo *
*;
//输出数据库中记录到表格
while (!$rs->eof)
{
echo *
*;
for ($j = 0; $j < $rs->Fields->count(); $j++)
{
echo *
* . $rs->Fields($j)->value . **;
}
echo *
*;
$rs->MoveNext();
}
echo *
*;
?>
如果觉得《pHP调用accdb php如何连接access的accdb格式数据库文件?》对你有帮助,请点赞、收藏,并留下你的观点哦!