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) Download the appropriate 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, (after my test is not so) copy them to the appropriate directory (or install PHP4 default directory C:\php4\peer\, or the current running program directory , depending on the include () function);
(3) Then in the c:\myphp directory of the Machine (under IIS settings through the HTTP://LOCALHOST/JHK to access), built an access library called Test.mdb, the inside of a table to recreate the experts .... 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:
Copy CodeThe code is as follows: 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 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:
Copy CodeThe code is as follows: Include (' tohtml.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 = ' 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.
It's all done! (After my test does not really solve the problem), you can read the next article, you know
http://www.bkjia.com/PHPjc/317513.html www.bkjia.com true http://www.bkjia.com/PHPjc/317513.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 Web ...