Nominate our 2022 Qt Champions!

Connection problem with an access file under Linux

  • Hello to all.

    The problem I would like to address concerns the reading of a DB within an Access file under a Linux operating system.

    I have already followed this guide ( and installed unixODBC drivers.

    I’ll show you the code i’m using to connect to the DB:

      QSqlDatabase mydb;
        void connectionClose()
     bool connectionOpen(){
                mydb = QSqlDatabase::database("Contact");
               if (mydb.isOpen()) {
                   return true;
                   static QString path = PATH;
                   path = QDir::toNativeSeparators(path);
                   mydb = QSqlDatabase::addDatabase("QODBC", "Contact");
                   QString params="Driver={Microsoft Access Driver (*.mdb,*.accdb)};FIL={Access};DBQ="+ path;
                   qDebug() <<"path --> " + params;
                   if (!
                       qDebug() << "Error: connection with database fail";
                       qDebug() << mydb.lastError().text();
                       return false;
                       qDebug() << "Database: connection ok";
                       return true;
                   return true;

    The error that my application launches when trying to access DB data is:

    "path --> Driver={Microsoft Access Driver (*.mdb,*.accdb)};FIL={Access};DBQ=/home/rusty/QTProjects/build-Beta-Desktop_Qt_5_9_1_GCC_64bit-Release/ContactEvo.mdb"
    Error: connection with database fail
    "[unixODBC][Driver Manager]Can't open lib 'Microsoft Access Driver (*.mdb,*.accdb)' : file not found QODBC3: Unable to connect"
    QSqlDatabasePrivate::database: unable to open database: "[unixODBC][Driver Manager]Can't open lib 'Microsoft Access Driver (*.mdb,*.accdb)' : file not found QODBC3: Unable to connect"

    Can you see where the mistake might be? The application under Windows runs without any kind of problem..

    thank you for your time!

  • Lifetime Qt Champion

    @Bruschetta said in Connection problem with an access file under Linux:


    Did you also install drivers for mdb ?

  • @mrjj
    Yes mbdTools is installed :(

  • Lifetime Qt Champion


    Im not sure you still must do this
    but did you also tell odbc about the driver ?


    Description = MDBTools Driver
    Driver =
    Setup =
    FileUsage = 1
    UsageCount = 1

  • Hi also you can look at this thread (it's also about reading Access .mdb files under Linux)

    Two conclusions from that thread: you'll need a patched version of qsql_odbc.cpp, otherwise you'll get these kind of errors once the odbcxxx.ini files are fixed:
    Error at Line : syntax error near 'test'
    syntax error near 'test'
    Got no result for 'select 'test'' command
    QODBCDriver::checkHasSQLFetchScroll: Warning - Driver doesn't support scrollable result sets, use forward only mode for queries

    and also, even with the patched version qsql_odbc.cpp, the mdbtools driver seems to be read-only with very limited functionality :-(

    P.S. isql is your friend

Log in to reply