0

I am trying to get data from a MS Access DB (.mdb) but I'm getting:

échec de connexion: SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][Gestionnaire de pilotes ODBC] Source de données introuvable et nom de pilote non spécifié.

English:

connection failure: SQLSTATE [IM002] SQLDriverConnect: 0 [Microsoft] [ODBC driver manager] data source not found and driver name unspecified.

I have : Office 365 Business 32-bit installed. Already installed the latest Access Database Engine 32-bit. Uncommented " extension=pdo_odbc " in php.ini. Added the "Microsoft Access Driver" to the list of drivers.

$dbName = 'C:\wamp64\www\Test\Workgroup.mdb';
if (!file_exists($dbName))
{
    die("Could not find database file.");
}
else
{
    try{
        //$dbName = 'Workgroup.mdb';
        $cnx = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; Dbq=$dbName; Uid=; Pwd=;");
        echo "connected successfully";
        return $cnx;
    }
    catch(Exception $e){
        die ("failed to connect: " . $e->getMessage());
    }
}
3
  • $dbName in the Try block does not appear to have full file path. Why do you set the variable here? Commented Mar 28, 2019 at 21:50
  • Just forgot to comment it, it was for the purpose of testing. Commented Mar 29, 2019 at 8:55
  • Review stackoverflow.com/questions/13103712/… Commented Mar 29, 2019 at 9:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.