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. QSqlQuery and error handing ?
Forum Update on Monday, May 27th 2025

QSqlQuery and error handing ?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 403 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.
  • S Offline
    S Offline
    SPlatten
    wrote on 16 Feb 2019, 18:50 last edited by SPlatten
    #1

    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
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 16 Feb 2019, 19:26 last edited by
      #2

      Hi

        if ( query.lastError().type() == QSqlError::NoError  ) {
              qDebug() << "no error";
          }
      
      1 Reply Last reply
      3
      • S Offline
        S Offline
        SPlatten
        wrote on 16 Feb 2019, 19:27 last edited by
        #3

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

        Kind Regards,
        Sy

        M 1 Reply Last reply 16 Feb 2019, 19:28
        0
        • S SPlatten
          16 Feb 2019, 19:27

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

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 16 Feb 2019, 19:28 last edited by
          #4

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

          1 Reply Last reply
          4

          1/4

          16 Feb 2019, 18:50

          • 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