3

I've tried a lot of things.

query.isNull()

tried the query.Record() then int col = query.Record()

if I put query.size() it will return -1 even if the query has result.

How do i count queries in SQLite?

I wanted to do this:-

 if(the query returns null or empty) 
 {
  do this;
 }
  else 
 {
  do that;
 }
1
  • Are you trying to count the number of rows that will be returned without fetching them all? (You can't: the DB engine doesn't know how many there are until it gets to the end. In a complex query, this is enormously helpful.) Commented May 30, 2011 at 9:55

1 Answer 1

8

query.size() does not work with the SQlite database driver in Qt. You can do:

query.exec();
bool gotResults = false;
while (query.next()) {
  gotResults = true;
  // do something with the result using query.value(...)
}
if (!gotResults) {
  // do something else
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.