Home > front end >  How to show all tables of Microsoft Access PDO Object?
How to show all tables of Microsoft Access PDO Object?

Time:07-16

$tdb = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=$sdltdbsavedfilename; Uid=; Pwd=;");
$sql = 'SHOW TABLES';
$tdbresult = $tdb->query($sql);
var_dump($tdbresult);

Gives: Fatal error: Uncaught PDOException: SQLSTATE [42000] : Syntax error or access violation: [Microsoft] [ODBC Microsoft Access Driver] SQL statement is not correct. Use 'DELETE' 'INSERT', 'PROCEDURE', 'SELECT' OR 'UPDATE'. (SQLPrepare [0] at ext\pdo_odbc\odbc_driver.c:203)

What is the right way?

CodePudding user response:

Try query the system table:

$sql = 'Select Name From MSysObjects Where Flags = 0 And Type = 1';

CodePudding user response:

In the end I went for this solution instead:

Check if a database table exists using PHP/PDO

So instead of searching all tables, I just try one and check whether it exists before proceeding.

  • Related