Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Not able to open Microsoft Access file
Forum Update on Monday, May 27th 2025

Not able to open Microsoft Access file

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 894 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rockon209
    wrote on last edited by rockon209
    #1

    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");

    if(db.open())
    qDebug() << "oK";
    else
    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

    K 1 Reply Last reply
    0
    • R rockon209

      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");

      if(db.open())
      qDebug() << "oK";
      else
      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

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @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.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      1
      • R Offline
        R Offline
        rockon209
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved