I read the article "How to invoke Asscess database and COM program in PHP through ADO", immediately after the test, the result failed. Sad isn't it.
What to do? I had to go to the official PHP website for help, emperor not negative, finally I found the answer--
The specific solution is as follows:
(1) Download the corresponding zip package; like Microsoft's ADO, it uses PHP to implement ADO to deal with a variety of databases (great, all types of databases can handle).
(2) Unpack, there are a lot of documents, but only useful ohtml.inc.php and adodb.inc.php, (not by my test) to copy them to the appropriate directory (or install the PHP4 default directory C:\php4\peer\, or the current running program directory , depending on the include () function);
(3) Then in the local c:\myphp directory (IIS set up through the HTTP://LOCALHOST/JHK to access), built a access library called Test.mdb, inside the experts table rebuilt .... To access it through DSN, I named Test in the DSN for the Access library I just had.
(4) run. Looking at the instructions, I built this program:
dbtest.php, the contents are as follows:
Copy Code code as follows:
<?php
Include (' tohtml.inc.php '); Load code common to ADODB
Include (' adodb.inc.php '); Load code common to ADODB
$conn = &adonewconnection (' access '); Create a connection
$conn->pconnect (' test ');/connect to MySQL, Agora DB
$sql = ' Select name, group1 from experts ';
$rs = $conn->execute ($sql);
Rs2html ($rs, ' border=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 result came out. Basic Satisfaction!!
(5) Then, I think: also to set DSN, annoying not annoying! How do I solve a DSN bypass? Because in ASP, I am accustomed to use Conn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (". /nydatabase.mdb ") to handle the MDB library, that's fast!
? ...... Think and think, look and see ...
Look for, ..., hey, finally found the answer in testdatabases.inc.php! I'm going to adapt the procedure just now:
Copy Code code as follows:
<?php
Include (' tohtml.inc.php '); Load code common to ADODB
Include (' adodb.inc.php '); Load code common to ADODB
$db = &adonewconnection ("ado_access");
Print "$access = ' Test.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, ' border=2 cellpadding=3 ', Array (' Customer Name ', ' Customer ID '));
else print ' error:access test requires a Access database $access. '
'. $db->errormsg ();
?>
Run.
Everything's done! (After my test can not actually solve the problem), we will see the next one, we know