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. Transactions in Microsoft Access
Forum Update on Monday, May 27th 2025

Transactions in Microsoft Access

Scheduled Pinned Locked Moved Solved General and Desktop
transactionsms-access
4 Posts 2 Posters 930 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.
  • P Offline
    P Offline
    PinTxO
    wrote on 29 May 2018, 07:54 last edited by
    #1

    Hi guys.

    I have a database (.mdb) and I connect to it from my QT application. I do not have problems to read the data but when I save it, I want to do it through a transaction and I can not because I'm having an error. I paste how I open the connection and how I launch the transaction:

    The connection:

    m_db = QSqlDatabase::addDatabase("QODBC");
    QString strPathDDBB="DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=" + QCoreApplication::applicationDirPath() + "/galibo.mdb";
    m_db.setDatabaseName(strPathDDBB);
    if (!m_db.open()) {
        QMessageBox::critical(0, QObject::tr("Database Error"), m_db.lastError().text());
      }
    

    The transaction:

    bool feature = m_db.driver()->hasFeature(QSqlDriver::Transactions);
    if (!m_db.transaction())
    {
        error = "An error occurred while creating the transaction in the database\n";
        error += m_db.lastError().text();
        return false;
    }
    

    The feature variable returns true and the text error is "[Microsoft] [Microsoft Access ODBC Driver] Unable to define attribute now QODBC3: Unable to disable autocommit"

    Any ideas?

    P 1 Reply Last reply 29 May 2018, 15:24
    0
    • P PinTxO
      29 May 2018, 07:54

      Hi guys.

      I have a database (.mdb) and I connect to it from my QT application. I do not have problems to read the data but when I save it, I want to do it through a transaction and I can not because I'm having an error. I paste how I open the connection and how I launch the transaction:

      The connection:

      m_db = QSqlDatabase::addDatabase("QODBC");
      QString strPathDDBB="DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=" + QCoreApplication::applicationDirPath() + "/galibo.mdb";
      m_db.setDatabaseName(strPathDDBB);
      if (!m_db.open()) {
          QMessageBox::critical(0, QObject::tr("Database Error"), m_db.lastError().text());
        }
      

      The transaction:

      bool feature = m_db.driver()->hasFeature(QSqlDriver::Transactions);
      if (!m_db.transaction())
      {
          error = "An error occurred while creating the transaction in the database\n";
          error += m_db.lastError().text();
          return false;
      }
      

      The feature variable returns true and the text error is "[Microsoft] [Microsoft Access ODBC Driver] Unable to define attribute now QODBC3: Unable to disable autocommit"

      Any ideas?

      P Offline
      P Offline
      Pablo J. Rogina
      wrote on 29 May 2018, 15:24 last edited by
      #2

      @PinTxO Maybe the issue is outside scope of Qt, and related to the ODBC driver you're using. Have you checked using that same driver with other application?
      Your error "Unable to disable autocommit" maybe is related to some settings in the connection/database? As this post may clarify about transactions.
      And also from your error "Unable to define attribute now QODBC3" this fragment from Qt's QODBC documentation may apply:

      By default, Qt instructs the ODBC driver to behave as an ODBC 2.x driver. However, for some driver-manager/ODBC 3.x-driver combinations (e.g., unixODBC/MaxDB ODBC), telling the ODBC driver to behave as a 2.x driver can cause the driver plugin to have unexpected behavior. To avoid this problem, instruct the ODBC driver to behave as a 3.x driver by setting the connect option "SQL_ATTR_ODBC_VERSION=SQL_OV_ODBC3" before you open your database connection. Note that this will affect multiple aspects of ODBC driver behavior, e.g., the SQLSTATEs. Before setting this connect option, consult your ODBC documentation about behavior differences you can expect.

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2
      • P Offline
        P Offline
        PinTxO
        wrote on 30 May 2018, 06:59 last edited by
        #3

        Thanks Pablo for answering.

        I have already found out the reason for the error. The transaction is launched in the process of saving the application. Before this process, a series of consultations are made in the process of reading the information. Well, if in each query, the resources are not released through finish() method of the QSqlQuery class, then, when the transaction is launched, the commented exception is skipped.

        Thank you

        P 1 Reply Last reply 30 May 2018, 12:13
        1
        • P PinTxO
          30 May 2018, 06:59

          Thanks Pablo for answering.

          I have already found out the reason for the error. The transaction is launched in the process of saving the application. Before this process, a series of consultations are made in the process of reading the information. Well, if in each query, the resources are not released through finish() method of the QSqlQuery class, then, when the transaction is launched, the commented exception is skipped.

          Thank you

          P Offline
          P Offline
          Pablo J. Rogina
          wrote on 30 May 2018, 12:13 last edited by
          #4

          @PinTxO ok, so it seems your issue is solved. If so, please don't forget to mark your post as such. Thanks.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          1

          1/4

          29 May 2018, 07:54

          • Login

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