<p>How can we connect a <code>PHP</code> script to <code>MS Access (.mdb)</code> file?</p>

<p>I tried by including following <code>PHP</code> code:</p>

<pre><code>$db_path = $_SERVER['DOCUMENT_ROOT'] . '\WebUpdate\\' . $file_name . '.mdb';
$cfg_dsn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" . $db_path;
$odbcconnect = odbc_connect($cfg_dsn, '', '');
</code></pre>

<p>But it failed and I received following error message:</p>

<pre><code> Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\web\WebUpdate\index.php on line 41
</code></pre>

Here's a sample for a connect and a simple select...
```
```
<?php
$db_conn = new COM("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("./Northwind.mdb").";";
$db_conn->open($connstr);
$rS = $db_conn->execute("SELECT * FROM Employees");
$f1 =  $rS->Fields(0);
$f2 =  $rS->Fields(1);
while (!$rS->EOF)
{
    print $f1->value." ".$f2->value."<br />\n";
    $rS->MoveNext();
}
$rS->Close();
$db_conn->Close();
?>
```
```