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. Connect to access data base in win32 and x64 with odbc driver
Forum Updated to NodeBB v4.3 + New Features

Connect to access data base in win32 and x64 with odbc driver

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 15.3k 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.
  • G Offline
    G Offline
    gemblev
    wrote on last edited by
    #1

    Hello,

    My Qt application designed on Win32 works fine to connect to an access database through odbc driver.
    Since, I generated this application with x64, so it cannot connect with the access database.

    versions

    • windows 7 pro
    • visual studio 2008
    • qt V4.6.2
    • toto.mdb is the access file generated by access 2003

    The win32 configuration files :

    • odbccad32 in Windows\SysWOW64 with odbcad32 that drives Microsoft Access Driver (*.mdb) Version 6.01.7601.17632
    • odbc32.dll in Windows\SysWOW64 v6.1.7601.17514
    • odbcint.dll in Windows\SysWOW64 v6.1.7600.16385
    • The qt dll plugins is:
      .\Debug\sqldrivers\qsqlodbcd4.dll

    The x64 configuration files

    • I have installed Microsoft Access Database Engine 2010 Redistributable
    • odbccad32 in Windows\system32 with odbcad32 that drives Microsoft Access Driver (*.mdb, *.accdb) Version 14.00.4760.1000
    • odbc32.dll in Windows\system32 v6.1.7601.17514
    • odbcint.dll in Windows\system32 v6.1.7600.16385
    • The qt dll plugins is:
      .\Debug\sqldrivers\qsqlodbcd4.dll
      @QString dbName;
      QSqlDatabase m_db;

    m_db = QSqlDatabase::addDatabase("QODBC");
    dbName = "DRIVER={Microsoft Access Driver (*.mdb)};DSN='';DBQ=toto.mdb";
    m_db.setDatabaseName(dbName);
    m_db.setConnectOptions("SQL_ATTR_ACCESS_MODE=SQL_MODE_READ_ONLY");

    the source code
    if(m_db.open())
    {
    qDebug() << "oK";
    m_db.close();
    }
    else
    {
    qDebug() << m_db.lastError().text();
    }@

    Dll log is:

    • .\Debug\sqldrivers\qsqlodbcd4.dll is loaded
    • Windows\system32\odbc32.dll is loaded
    • Windows\system32\odbcint.dll is loaded

    Error log is :

    • Error in french: [Microsoft][Gestionnaire de pilotes ODBC] Source de données introuvable et nom de pilote non spécifié QODBC3: Unable to connect
      Error in english: [Microsoft] [ODBC Driver Manager] Data source name not found and no default driver specified.

    Help please !

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gemblev
      wrote on last edited by
      #2

      I solved this problem, and now my application generated wih x64 connects to Access Data Base.

      The name of the driver must be written exactly as you see on ODBC management: Windows\system32\odbccadd32. The ODBC driver for access shows : DRIVER={Microsoft Access Driver (*.mdb, *.accdb)

      source code
      @#ifdef _WIN64
      dbName = "DRIVER={Microsoft Access Driver (*.mdb, .accdb)}'';DBQ=toto.mdb";
      #else
      dbName = "DRIVER={Microsoft Access Driver (
      .mdb)};DBQ=toto.mdb";
      #endif@

      The driver odbc for access x64:
      http://www.microsoft.com/en-us/download/details.aspx?id=13255

      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