Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. QSqlQuery::isValid with MySql

QSqlQuery::isValid with MySql

Scheduled Pinned Locked Moved Solved 3rd Party Software
3 Posts 2 Posters 1.6k 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.
  • K Offline
    K Offline
    koahnig
    wrote on last edited by
    #1

    I started to use MySql through Qt. In my table I have records which require update when some of the key numbers are already available in a relation. Therefore I have to use "CREATE" once and afterwards "UPDATE".

    With a query on "SELECT * FROM table WHERE VAL=..." I am checking the existance of the reocrd. I expected that the query would deliver with isValid() == true for existing extry, but the return value is always false. I can use the size statement, which shall be 1 then. However, is there a better way for checking?

    Vote the answer(s) that helped you to solve your issue(s)

    A 1 Reply Last reply
    0
    • K koahnig

      I started to use MySql through Qt. In my table I have records which require update when some of the key numbers are already available in a relation. Therefore I have to use "CREATE" once and afterwards "UPDATE".

      With a query on "SELECT * FROM table WHERE VAL=..." I am checking the existance of the reocrd. I expected that the query would deliver with isValid() == true for existing extry, but the return value is always false. I can use the size statement, which shall be 1 then. However, is there a better way for checking?

      A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      @koahnig You need to call next() before isValid() returns true or not. You can also test the return value of next().

      And of course testing the size as you are doing works fine as well.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      K 1 Reply Last reply
      3
      • A ambershark

        @koahnig You need to call next() before isValid() returns true or not. You can also test the return value of next().

        And of course testing the size as you are doing works fine as well.

        K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        @ambershark

        Thanks. The documentation for isValid is a bit ambiguous when reading as stand-alone.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        2

        • Login

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