How can I know if a SELECT access an invalid position? e.g position 651 is a not valid position in my data base but my code does not show an error:
query.prepare("SELECT creationDate, state FROM jobs WHERE jobId = '" + QString::number(651) + "'");
error = query.lastError().text();
if (query.exec())
{
query.first();
qDebug() << query.value(0).toString();
qDebug() << query.value(1).toString();
}
else
qDebug() << error;
Thank you very much.
You have to check if
first()is true.http://doc.qt.io/qt-5/qsqlquery.html#first