guidupas
11th February 2015, 14:13
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
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