Home  >  Article  >  php教程  >  PHP中通过ADODB库实现调用Access数据库之修正版本 原创

PHP中通过ADODB库实现调用Access数据库之修正版本 原创

WBOY
WBOYOriginal
2016-06-13 12:35:06992browse

最主要的下载地址了,请先看上一篇文章。
http://adodb.sourceforge.net/#download

本地下载 下载此文件
此文件解压后放到adodb目录里,最好是全部啊,不是只有ohtml.inc.php和adodb.inc.php
引用的确实只要这两个就可以了

复制代码 代码如下:


include('adodb/tohtml.inc.php'); // load code common to ADODB
include('adodb/adodb.inc.php'); // load code common to ADODB
$db = &ADONewConnection("ado_access");
print "

Connecting $db->databaseType...

";
$access = 'E:\php\phpaccess\test.mdb';
$myDSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;'.'DATA SOURCE='. $access.';USER ID=;PASSWORD=;';
//注意了,mdb地址是物理地址啊
if (@$db->PConnect($myDSN, "", "", "")) {
print "ADO version=".$db->_connectionID->version.";
";
$sql = 'select thename from news';
$rs = $db->Execute($sql);
rs2html($rs,'border=2 cellpadding=3',array('Customer Name','Customer ID'));
} else print "ERROR: Access test requires a Access database $access".';
'.$db->ErrorMsg();
?>

数据库呢,普通的access数据库,和正常的一样,不需注意什么
测试通过。如果有更好的建议请,请在评论里指出
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn