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 Updated to NodeBB v4.3 + New Features

QSqlQuery and error handing ?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 435 Views 2 Watching
  • 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on 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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi

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

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

        Kind Regards,
        Sy

        mrjjM 1 Reply Last reply
        0
        • SPlattenS SPlatten

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

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          1 Reply Last reply
          4

          • Login

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