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. [SOLVED] Firebird select returns -2 result
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Firebird select returns -2 result

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 599 Views 1 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.
  • G Offline
    G Offline
    guidupas
    wrote on 11 Feb 2015, 13:13 last edited by
    #1

    Hello!

    I am facing a problem with a firebird SELECT. When I try to count the number of rows returned it returns the value -2

    Does anyone know why?

    @
    bool queryRetornoDB::retornaValidadeUsuarioSistema()
    {
    bool retorno;
    //retorno = true;
    retorno = false;

    QSqlQuery resultadoQuery;
    
    QString query = "SELECT * FROM usuario u";
    
    resultadoQuery.exec(query);
    
    int resultadoQueryNumLinhas = this->retornaQueryNumLinhas(resultadoQuery);
    
    qDebug() << "Valida usuário: ";
    qDebug() << resultadoQueryNumLinhas;
    

    }
    @

    @
    int queryRetornoDB::retornaQueryNumLinhas(QSqlQuery query)
    {
    query.last();
    int linhas = query.at() + 1;
    return linhas;
    }
    @

    Thanks

    Att.
    Guilherme Cortada Dupas

    1 Reply Last reply
    0
    • G Offline
      G Offline
      guidupas
      wrote on 11 Feb 2015, 21:26 last edited by
      #2

      Solved

      @
      int queryRetornoDB::retornaQueryNumLinhas()
      {

      int retorno = -1;
      
      QSqlQuery resultadoQuery = "SELECT COUNT(*) FROM validador v";
      
      if(resultadoQuery.exec&#40;query&#41;)
      {
          resultadoQuery.next();
      
          retorno = resultadoQuery.value(0).toInt();
      }
      
      return retorno;
      

      }
      @

      Att.
      Guilherme Cortada Dupas

      1 Reply Last reply
      0

      1/2

      11 Feb 2015, 13:13

      • Login

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