Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Sqlite commit fails - "cannot commit - no transaction is active Unable to commit transaction"



  • I am doing sql transaction in qt.

    bool X::save()
    {
      mDatabase.transaction();
    
      if (!saveHeader())
      {
           mDatabase.rollback();
           return false;
      }
      
      if (!saveBody())
      {
           mDatabase.rollback();
           return false;
      }
    
      mDatabase.commit();     
      return true;
    }
    

    My commit returns fails an returns "cannot commit - no transaction is active Unable to commit transaction"

    I have SELECT and DELETE query in the functions. But I do query.clear(); after execution.

    Still I get this error. Someone knows why...



  • @Abin

    Hi, IMO you should not use query.clear(). Did you try to run without this?


Log in to reply