Please read the post immediately above yours. Only some database engines support reporting the number of rows returned in a query. For Sqlite:
qDebug
() << db.
driver()->hasFeature
(QSqlDriver::QuerySize);
// Output
false
QSqlDatabase db;
qDebug() << db.driver()->hasFeature(QSqlDriver::QuerySize);
// Output
false
To copy to clipboard, switch view to plain text mode
If you only want to know if a record exists then:
//Metodo que procura uma tag através do seu nome
bool BaseDados
::procurarTagPeloNome(const QString &nome
){ query.prepare("SELECT 1 FROM tag WHERE nome=:nome ");
query.bindValue(":nome", nome);
return query.exec() && qry.next();
// If the query succeeds and returns a row (or more) then returns true.
}
//Metodo que procura uma tag através do seu nome
bool BaseDados::procurarTagPeloNome(const QString &nome){
QSqlQuery query;
query.prepare("SELECT 1 FROM tag WHERE nome=:nome ");
query.bindValue(":nome", nome);
return query.exec() && qry.next();
// If the query succeeds and returns a row (or more) then returns true.
}
To copy to clipboard, switch view to plain text mode
Bookmarks