0

I'm really in need of assistance with this issue, ive been trying for days. I have an access database which i'm trying to query via PHP - i have come to this forum because after reading many posts and trying different things i am certain that this is some kind of issue on the server.

I have installed Microsoft access database engine, both 2010 and the 2007 version but whatever i try i get the same error message :

 Uncaught exception 'com_exception' with message '<b>Source:</b> ADODB.Connection<br/><b>Description:</b> Provider cannot be found.

I have uncommented all the relative lines in php.ini (after crawling through many stack overflow posts with the same issue) but with no success. Below is the code i am using in my php file.

<?php

// Create an instance of the ADO connection object
$conn = new COM ("ADODB.Connection") or die("Cannot start ADO");

// Define the connection string and specify the database driver
$connStr = "PROVIDER=Microsoft.Ace.OLEDB.12.0;Data Source=".realpath("HS_BE.accdb").";";

// Open the connection to the database
$conn->open($connStr);

// Declare the SQL statement that will query the database
$query = "SELECT * FROM Accommodation";

// Execute the SQL statement and return records
$rs = $conn->execute($query);

$num_columns = $rs->Fields->Count();
echo $num_columns . "<br>"; 

for ($i=0; $i < $num_columns; $i++) {
    $fld[$i] = $rs->Fields($i);
}

echo "<table>";

while (!$rs->EOF)  // Carry on looping through while there are records
{
    echo "<tr>";
    for ($i=0; $i < $num_columns; $i++) {
        echo "<td>" . $fld[$i]->value . "</td>";
    }
    echo "</tr>";
    $rs->MoveNext(); // Move on to the next record
}

echo "</table>";

// Close the connection and recordset objects freeing up resources 
$rs->Close();
$conn->Close();

$rs = null;
$conn = null;
?>

Id be very grateful for some assistance!

G.Smith
  • 141
  • 11
  • 1
    Possible duplicate of [Getting Error 800a0e7a "Provider cannot be found. It may not be properly installed."](http://stackoverflow.com/questions/21719422/getting-error-800a0e7a-provider-cannot-be-found-it-may-not-be-properly-install) – Kamil Karkus Apr 18 '16 at 21:36
  • I tried everything on that earlier and didnt work – G.Smith Apr 18 '16 at 22:12
  • do you have to use COM objects? PDO might be a better way forward perhaps – Professor Abronsius Apr 18 '16 at 22:23
  • Ive tried PDO and COM – G.Smith Apr 19 '16 at 07:24
  • Your [other question](http://stackoverflow.com/q/36696034/2144390) indicates that your PHP is running as 32-bit and you have the 64-bit version of the Access Database Engine installed. If that is still the case then it's the same problem. – Gord Thompson Apr 19 '16 at 21:06

0 Answers0