Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Not able to open Microsoft Access file

    General and Desktop
    2
    3
    754
    Loading More Posts
    • 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
      rockon209 last edited by 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 1 Reply Last reply Reply Quote 0
      • K
        koahnig @rockon209 last edited by

        @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 Reply Quote 1
        • R
          rockon209 last edited by

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post