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 next()

QSqlQuery next()

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.7k Views 3 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.
  • C Offline
    C Offline
    ckvsoft
    wrote on last edited by koahnig
    #1

    Pls how next() return always true?

    QSqlQuery query;
    query.prepare("SELECT firstName FROM employee WHERE name = ?");
    query.bindValue("MyName");
    query.exec();
    

    query next ist allways true. Table is empty

    if (query.next()) {
        QString firstName = query.value(0).toString(); // this work without fail
        // firstName is NULL;
    }
    

    is there an other way to find out if we got one ore more records?

    [edit: koahnig. Code tags added]

    K 1 Reply Last reply
    0
    • C ckvsoft

      Pls how next() return always true?

      QSqlQuery query;
      query.prepare("SELECT firstName FROM employee WHERE name = ?");
      query.bindValue("MyName");
      query.exec();
      

      query next ist allways true. Table is empty

      if (query.next()) {
          QString firstName = query.value(0).toString(); // this work without fail
          // firstName is NULL;
      }
      

      is there an other way to find out if we got one ore more records?

      [edit: koahnig. Code tags added]

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

      @ckvsoft

      Please use code tags in your postings. This makes code sections more readable.

      Checkout size()

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

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ckvsoft
        wrote on last edited by
        #3

        thx

        I't seem this issue is only when i debug the code, when i put a qDebug in the lines and run my app i can see that next() will return false. confused

        the_T 1 Reply Last reply
        0
        • C ckvsoft

          thx

          I't seem this issue is only when i debug the code, when i put a qDebug in the lines and run my app i can see that next() will return false. confused

          the_T Offline
          the_T Offline
          the_
          wrote on last edited by
          #4

          @ckvsoft which Qt version and compiler do you use?

          -- No support in PM --

          1 Reply Last reply
          0

          • Login

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