Planned maintenance: From Sunday 8th December 10:00 CET there will be changes to try and solve the caching issues that have been experienced. If anyone has a problem connecting after this period then please PM @AndyS or any of the moderators.

Not able to open Microsoft Access file

  • Hello everyone i am using the following code to open the Microsoft Access file

    QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    db.setDatabaseName("DRIVER={Microsoft Access Driver(*.accdb)};FIL={MS Access};DBQ=C:\..\...\....\Database1.accdb");

    qDebug() << "oK";
    qDebug() << db.lastError();

    and i am getting the following error
    QSqlError("0", "QODBC3: Unable to connect", "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified")
    please help- Thanks in advance

  • @rockon209 said in Not able to open Microsoft Access file:

    ODBC Driver Manager] Data source name not found and no default driver specified

    Sometimes Google is your best friend

    Considering the relative path you are using that link will probably give a hint (found with the Google search above)

    OK, just saw that your relative path might be a stripped down absolute path and trying to hide the details.
    Checkout the details there. The db has to be there where you expect it.
    Note: Single backslash are typically not a good idea in C/C++ and for absolute and relative file path, they are deadly. Use single forward slashes which are also supported by Windows and common on other OS.

  • @koahnig
    I tried with two back slashes and with forward slashes also but both gave me same error

Log in to reply