php连接access数据库为什么老是出错?
程序如下,运行的时候老是提示错误(数据库没有密码和用户名设置):Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft OLE DB Provider for ODBC Drivers
Description: Operation was canceled.' in C:\Documents and Settings\han0000t\workspace\hantao\access.php:19
Stack trace:
#0 C:\Documents and Settings\han0000t\workspace\hantao\access.php(19): com->open('driver=microsof...')
#1 {main}
thrown in C:\Documents and Settings\han0000t\workspace\hantao\access.php on line 19
有谁知道错在哪里,以及如何修改么?
先谢谢啦,
<?php
$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=".realpath("db/hallo.mdb");
$conn->Open($connstr);
$rs=new com("ADODB.RecordSet");
$rs->Open("select * from news",$conn,1,1);
while(!$rs->eof)
{
$f=$rs->Fields("title");
echo $f->value ."<br>";
$rs->MoveNext();
}
$rs->close();
?>
<?php
$dbc=new com("adodb.connection");
$dbc->open("driver=microsoft access driver (*.mdb);dbq=".realpath("db/hallo.mdb"));
//$rs=$dbc->Execute("select * from news");
$i=0;
while(! $rs->eof) {
echo $rs->Fields("title")->value."<br/>";
$rs->MoveNext();
}
?><br>
<br>
<?php
$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=".realpath("db/hallo.mdb");
$conn->Open($connstr);
$rs = new com("ADODB.RecordSet");
$rs->Open("select * from news",$conn,1,1);
while(! $rs->eof) {
echo $rs->Fields["title"]->value."<br/>";
$rs->MoveNext();
}
?>
[ 本帖最后由 天各一方2010 于 2011-3-25 17:55 编辑 ]