Accessing an Access db file (accdb) on Windows 64bit via PHP using ODBC


This is an old post from our original website back in 2014; but still seems to get some hits and is obviously useful for developers tackling this legacy problem...

Recently we’ve done a couple of small projects which have required using an existing access database. Generally this isn’t too much of an issue using PHPs PDO and ODBC functionality. You have to ensure that odbc and pdo_odbc are enabled in the php.ini and then:

$database = “C:\path\to\database.accdb”;
$db = new PDO(“odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$database;Uid=Admin”);

Cool, now you can query away using PDO as normal.

However, when we came to setting up the same code to run on a system running 64bit Windows 7 we came across an issue where the correct ODBC drivers weren’t installed and we were getting the error:

SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

If you find yourself in this situation, it turns out the solution was to install the file linked below:

I hope that’ll help someone else out there should you come across the issue.