Search code examples
phpdatabaseodbcms-access-2007

PHP Warning: odbc_connect(): SQL error: [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile)


MS Access Database Connect with PHP. When file found .accdb extension is not file found but .mdb.accdb database file is found and .mdb.accdb file is connect with php but only .accdb file is not connect with php

Give error :

"PHP Warning: odbc_connect(): SQL error: [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0xa34 Thread 0x1794 DBC 0x2010064 Jet'., SQL state S1000 in SQLConnect in "

<?php


$filename = 'C:\Website\Account\ABC\DataBase\AccountAaravStock.accdb';

if (file_exists($filename)) {
    echo "The file $filename exists";
} else {
    echo "The file $filename does not exist";

}

$conn = odbc_connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$filename","","");

if($conn){
    echo "Connected";

}else{

    echo "Failed";
}

?>

Solution

  • ODBC Driver and DSN information is stored in HKEY_LOCAL_MACHINE\SOFTWARE\ODBC registry key(user dsn info under HKEY_CURRENT_USER\SOFTWARE\ODBC).

    The error indicates that you do not have access to that registry key.

    To change the permissions for the key, please follow these instructions:

    1. Start Registry Editor (Regedt32.exe).
    2. Select the following key in the registry:
    3. HKEY_LOCAL_MACHINE\SOFTWARE\ODBC
    4. On the Security menu, click Permissions.
    5. Type the required permissions for the account that is accessing the Web page.
    6. Quit Registry Editor.

    Always back up the registry before you modify it