search
Homephp教程PHP源码PHP技巧--通过COM使用ADODB

<script>ec(2);</script>
要实现下列功能,请确保 php.ini 中的 com.allow_dcom 选项已设为 true。
一、准备工作
新建一个ACCESS数据库,并命名为db.mdb,然后在这个数据库中新建一个表 comtest,包含 id 和 title 两个字段,最后随便插入一些数据。
二、实现代码
// 就是刚建的数据库
$db = 'd:wwwrootdb.mdb';
// 建立连接,并打开
$conn = new COM('ADODB.Connection') or die('can not start Active X Data Objects');
//$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db");
$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$db");
// 执行查询并输出数据
$rs = $conn->Execute('SELECT * FROM comtest');
?>



while (!$rs->EOF) {
echo '';
echo '';
echo '';
echo '';
$rs->MoveNext();
}
?>
ID Title
'. $rs->Fields['id']->Value .''. $rs->Fields['title']->Value .'

// 释放资源
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
?>
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools