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";
}
Don’t do it, especially in C++, it’s asking to have serious security problems.
– Maniero