Not returning the value when I use the QT C ++ query

1

When I use the following query to return the docile of the bank's data, the following message appears: QSqlQuery :: value: not positioned on a valid record

I use the same code model and it is working, only the one that does not, it follows the code below:

QString ConfereNome = ui->lineEditNovoCampo->text();
    QSqlQuery queryVerificaSeCampoJaExiste("SELECT CdCampos FROM tbcampos WHERE NmCampos='"+ConfereNome+"'");
    if(queryVerificaSeCampoJaExiste.exec())
    {
        while(queryVerificaSeCampoJaExiste.next());
        {
            VerificadorIdExisteOuNao = queryVerificaSeCampoJaExiste.value(0).toString();
            qDebug()<<VerificadorIdExisteOuNao;
            qDebug()<<"Codigo do compo selecionado com sucesso!";
        }
    }
    else
    {
        qDebug()<<"Não foi possivel executar a query que verifica se o campo ja existe";
    }
    
asked by anonymous 19.07.2017 / 15:04

0 answers