RE: [PHP] How Can I establish an DSN-less connection to Access database?
| From: | Matthias Endler | Date: | Fri, 13 Oct 2000 16:22:39 +0000 |
| Subject: | RE: [PHP] How Can I establish an DSN-less connection to Access database? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-20038@lists.php.net to get a copy of this message | ||
> Hi.
>
> How Can I establish an DSN-less connection to an Access database?
> My Database is not an ODBC-Datasource, known, to Windows
> I get it by e-mail and want to extract some Data from it, using
> just full Windows path to this database
>
> Can this be done?
> Some code extract would help me very much
>
> Thanx in advance
> Yurij
>
>
Hi Yurij,
yes this is possible, but not with PHPs odbc_*-function. Instead you must
use a COM object. Here's a code snipped which requires ADO to be installed
on your machine. If you have IIS 4 or M$ PWS installed on your machine
there's a greate chance you have ADO installed as well.
<?
$dbc = new COM("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)};";
$connstr .= "DBQ=C:\\path\\to\\db\\test.mdb;uid=;pwd=;";
$dbc->open($connstr);
$rs = $dbc->execute("SELECT * FROM test");
while(!$rs->eof()) {
print $rs->fields['id']->value();
print "|".$rs->fields['name']->value()."<br>";
$rs->movenext();
}
$dbc->close();
?>
Hope this will help you.
Matthias aka Matthew
--
$ [ Where is Jimmy Hoffa?
[: missing `]´
--
$ [ Where is Jimmy Hoffa?
[: missing `]´