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. QSqlDatabase with Ms Access database
Qt 6.11 is out! See what's new in the release blog

QSqlDatabase with Ms Access database

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 3.8k Views 1 Watching
  • 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.
  • O Offline
    O Offline
    Ongsk
    wrote on last edited by
    #1

    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));
    
        msAccess.open();
        if(msAccess.isOpen())
        {
            this->setWindowTitle("Open");
        }
        else
        {
            this->setWindowTitle(msAccess.lastError().text());
        }
    

    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?

    Thks

    O 1 Reply Last reply
    0
    • O Ongsk

      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));
      
          msAccess.open();
          if(msAccess.isOpen())
          {
              this->setWindowTitle("Open");
          }
          else
          {
              this->setWindowTitle(msAccess.lastError().text());
          }
      

      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?

      Thks

      O Offline
      O Offline
      Ongsk
      wrote on last edited by
      #2

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

      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