I read the article, "How to invoke the Asscess database and COM program through ADO in PHP", and immediately tested it, the result failed. Sad isn't it.
What to do? I had to go to the official PHP website for help, emperor, and finally I found the answer--
The specific solution is as follows:
(1) Enter Http://php.weblogs.com/adodb, download the corresponding zip package; like Microsoft ADO, it uses PHP to implement ADO with a wide variety of databases (great, all types of databases can handle them).
(2) Unpacking, there are many files, but only useful ohtml.inc.php and adodb.inc.php, copy them to the appropriate directory (or install PHP4 default directory C:php4peer, or the current running program directory, depending on the include () function);
(3) Then in this chicken (the wrong word one, is the machine) in the c:myphp directory (IIS under the settings through the HTTP://LOCALHOST/JHK to access), built a library called Test.mdb, a experts of the table. To access it through DSN, I named the Access library in the DSN as test.
(4) run. Looking at the instructions, I built this program:
dbtest.php, the contents are as follows:
Include (ohtml.inc.php); Load code common to ADODB
Include (adodb.inc.php); Load code common to ADODB
$conn = &adonewconnection (Access); Create a connection
$conn->pconnect (EST);//Connect to MySQL, Agora DB
$sql = select name, group1 from experts;
$rs = $conn->execute ($sql);
Rs2html ($rs, order=2 cellpadding=3,array (Customer name,customer ID));
$rs->close (); Optional
$conn->close (); Optional
?>
Then, in IE, enter: http://localhost/jhk/dbtest.php
Alas! The results came out. Very basic Satisfaction!!
(5) Then, I thought: Also to set up DSN, not annoying! How should I resolve the DSN bypass? Because in ASP, I used to use Conn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (". /nydatabase.mdb ") to process the MDB library, that's fast!
? ...... Think and think, look and see ...
Look for, ..., hey, finally found the answer in the testdatabases.inc.php! I'm going to adapt the procedure:
Include (ohtml.inc.php); Load code common to ADODB
Include (adodb.inc.php); Load code common to ADODB
$db = &adonewconnection ("ado_access");
Print "
Connecting $db->databasetype ...
";
$access = Est.mdb;
$myDSN = provider=microsoft.jet.oledb.4.0;. DATA source=. $access. ;;. USER id=; password=;;
if (@ $db->pconnect ($myDSN, "", "", "")) {
Print "ADO version=". $db->_connectionid->version. "
";
$sql = select name, group1 from experts;
$rs = $db->execute ($sql);
Rs2html ($rs, order=2 cellpadding=3,array (Customer name,customer ID));
} else print "Error:access test requires a Access database $access".
. $db->errormsg ();
?>
Run.
It's all done!
This article related class file download address: http://www.phpe.net/?n=ShowClass&a=106
http://www.bkjia.com/PHPjc/531961.html www.bkjia.com true http://www.bkjia.com/PHPjc/531961.html techarticle I read the article, "How to invoke the Asscess database and COM program through ADO in PHP", and immediately tested it, the result failed. Sad isn't it. What to do? I had to go to the official PHP ...