Not returning the value when using the QT C++ query

Asked

Viewed 47 times

1

When I use the following query to return the database data code, the following message appears: Qsqlquery::value: not positioned on a Valid record

Use the same model code and the same is working, only not, follows below the code:

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";
    }
  • 1

    Don’t do it, especially in C++, it’s asking to have serious security problems.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.