Search code examples
c++databaseqtms-accessqodbc

Access Database - QODBC Driver Execute Grant On Admin


When attempting to execute the following statement with my .accdb file:

grant select on MSysObjects to Admin;

I get the following information back from QSqlError::text():

encountered SQL Error [[Microsoft][ODBC Microsoft Access Driver] Cannot open the Microsoft Access database engine workgroup information file. ODBC3: Unable to execute statement]

I understand that this issue might manifest itself in a .net environment if you have a corrupt or missing System.mdw file. The aforementioned file exists for me in the following directory:

C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Access

I'm trying to run SQL queries using QODBC using Qt framework. Is this some limitation of the Qt framework? Or am I missing something obvious here? I tried moving the System.mdw file into my applications bin directory to see if that would help (thinking that perhaps the application is failing to find the file in question) but unfortunately it makes no difference.

I am using Qt 5.12.0.


Solution

  • I needed to add the parameter SystemDB to my connection string to remove this error, as outlined in the connection string under Microsoft Access accdb ODBC Driver on the following page: https://www.connectionstrings.com/access/

    Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\mydatabase.accdb;
    SystemDB=C:\mydatabase.mdw;