Re: Access connection
| From: | Michael Louie Loria | Date: | Tue, 21 Jun 2005 02:51:18 +0000 |
| Subject: | Re: Access connection | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-26124@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160
>> Subject:
>> Access connection
>> From:
>> "Matt Murphy" <mmurphy@tc-tech.com>
>> Date:
>> Mon, 20 Jun 2005 16:33:52 -0500
>> To:
>> <php-windows@lists.php.net>
Here's a source code. Maybe you could try this but
it's OLE DB. It's
tested with NWIND or Northwind Access database. Just
the line $db =
'C:\\Program Files\\Microsoft Visual
Studio\\VB98\\NWIND.mdb'; if it's
on a diff. directory
- - - - - -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?
$db = 'C:\\Program Files\\Microsoft Visual
Studio\\VB98\\NWIND.mdb';
$conn = new COM('ADODB.Connection');
// Two ways to connect. Choose one.
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=$db");
//$conn->Open("DRIVER={Microsoft Access Driver
(*.mdb)}; DBQ=$db");
$sql = 'SELECT ProductName, QuantityPerUnit,
UnitPrice
FROM Products
ORDER BY ProductName';
$rs = $conn->Execute($sql);
?>
<table>
<tr>
<th>Product Name</th>
<th>Quantity Per Unit</th>
<th>Unit Price</th>
</tr>
<? while (!$rs->EOF): ?>
<tr>
<td><?= $rs->Fields['ProductName']->Value ?></td>
<td><?= $rs->Fields['QuantityPerUnit']->Value
?></td>
<td><?= $rs->Fields['UnitPrice']->Value ?></td>
</tr>
<? $rs->MoveNext() ?>
<? endwhile ?>
</table>
<?
$rs->Close();
$conn->Close();
?>
</body>
</html>
- - - - -
Michael Louie Loria
-----BEGIN PGP SIGNATURE-----
Comment: GPG Public Key:
https://www.biglumber.com/x/web?qs=0x4A256EC8
Comment: GPG Public Key:
http://www.lorztech.com/GPG.txt
Comment: Yahoo ID: michaellouieloria
iD8DBQFCsGwqEWLHf0olbsgRA+7KAJ9X3RBoA7//y9wQBcbjjPveNNG76gCgiGqG
6X8AjM0JbYLfwhi2ZnX7uzY=
=3nSR
-----END PGP SIGNATURE-----
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com