Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QSqlQuery and error handing ?

    General and Desktop
    2
    4
    171
    Loading More Posts
    • 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.
    • SPlatten
      SPlatten last edited by SPlatten

      I perform a query with:

      QSqlQuery query(strQuery);
      QSqlError err = query.lastError();
      

      What is the correct way to test 'QSqlError' to see if there is an error or not? I see that QSqlError has a member called, NoError. How do I test this?

      Looking at .number() I can see a value is returned, is there any lookup or list for these values?

      Kind Regards,
      Sy

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        Hi

          if ( query.lastError().type() == QSqlError::NoError  ) {
                qDebug() << "no error";
            }
        
        1 Reply Last reply Reply Quote 3
        • SPlatten
          SPlatten last edited by

          @mrjj , thank you, is there a list of what the various error numbers mean?

          Kind Regards,
          Sy

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @SPlatten last edited by

            @SPlatten
            Yes
            https://doc.qt.io/qt-5/qsqlerror.html
            alt text

            1 Reply Last reply Reply Quote 4
            • First post
              Last post