Important: Please read the Qt Code of Conduct -

QSqlDatabase with Ms Access database

  • hi:
    I tested a simple code in Win 7 (Qt 5.7 with MingGW 5.30 (32 bit)).

     QSqlDatabase msAccess =  QSqlDatabase::addDatabase("QODBC");
        QString sPath = QCoreApplication::applicationDirPath() + "/Database/Data.mdb";
        msAccess.setDatabaseName("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DSN='';DBQ="+ QDir::toNativeSeparators(sPath));

    The Apps work in release mode in the Win 7 PC but not in Win Xp.

    Error : [Microsoft][ODBC Driver Manager]Data Source name not found and no default driver specified QODBC3: Unable to Connect"

    I have Ms Access 2003 installed on Win XP PC, so I doubt is the driver.

    Any body face the same error like this?


  • FYI if you have the same problem as mine:

    Delete the *.accdb if your database is old as MS Access (OLEDB Jet 4.0)

    Driver={Microsoft Access Driver (*.mdb)};;DBQ=" + yourpathofdatabae + "/yourdatabase.mdb";

Log in to reply