Results 1 to 2 of 2

Thread: Transactions in Microsoft Access

  1. #1
    Join Date
    Oct 2015
    Qt products
    Qt4 Qt5

    Default Transactions in Microsoft Access

    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:
    Qt Code:
    1. m_db = QSqlDatabase::addDatabase("QODBC");
    2. QString strPathDDBB="DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=" + QCoreApplication::applicationDirPath() + "/galibo.mdb";
    3. m_db.setDatabaseName(strPathDDBB);
    4. if (! {
    5. QMessageBox::critical(0, QObject::tr("Database Error"), m_db.lastError().text());
    6. }
    To copy to clipboard, switch view to plain text mode 
    The transaction:
    Qt Code:
    1. bool feature = m_db.driver()->hasFeature(QSqlDriver::Transactions);
    2. if (!m_db.transaction())
    3. {
    4. error = "An error occurred while creating the transaction in the database\n";
    5. error += m_db.lastError().text();
    6. return false;
    7. }
    To copy to clipboard, switch view to plain text mode 

    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?
    Last edited by PinTxO; 29th May 2018 at 08:46.

  2. #2
    Join Date
    Oct 2015
    Qt products
    Qt4 Qt5

    Default Re: Transactions in Microsoft Access

    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

Similar Threads

  1. Connect to Microsoft Access 2010 *.accdb file
    By FuNkDaDdY in forum Newbie
    Replies: 11
    Last Post: 26th April 2018, 08:43
  2. Slow Microsoft Access QSqlQuery (possible bug)
    By yeikos in forum Qt Programming
    Replies: 0
    Last Post: 12th May 2014, 10:55
  3. select and edit like Microsoft Access with cute sql?
    By Everall in forum Qt Programming
    Replies: 4
    Last Post: 19th December 2010, 11:37
  4. Replies: 10
    Last Post: 30th September 2010, 06:16
  5. how to connect to a microsoft access database?
    By mismael85 in forum Qt Programming
    Replies: 3
    Last Post: 7th March 2008, 09:25

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.