[SOLVED] Firebird select returns -2 result
-
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
-
Solved
@
int queryRetornoDB::retornaQueryNumLinhas()
{int retorno = -1; QSqlQuery resultadoQuery = "SELECT COUNT(*) FROM validador v"; if(resultadoQuery.exec(query)) { resultadoQuery.next(); retorno = resultadoQuery.value(0).toInt(); } return retorno;
}
@