xiaocai 2006-3-14 20:15
php连接access数据库的问题,郁闷~~
为什么我一直连不上数据库??
以下是代码,大家帮忙看看~~
数据库文件在d:\data\test.mdb
<?php
$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("d:\data\test.mdb");
$conn->Open($connstr);
$rs = new com("ADODB.RecordSet");
$rs->Open("select * from person",$conn,1,1);
while(! $rs->eof) {
echo $rs->Fields["F_name"]->value."<br/>";
$rs->MoveNext();
}
?>
提示错误为
Warning: (null)(): Invoke() failed: 发生意外。 Source: Microsoft OLE DB Provider for ODBC Drivers Description: [Microsoft][ODBC Microsoft Access Driver] 文件名无效。
毛毛 2006-3-14 20:16
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="d:\\data\\test.mdb";
或
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="d:/data/test.mdb";
realpath()只是用来构造一个绝对路径,并不管该路径是否存在。
:lol:victory::victory::victory: