Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt and SQlite Database, How do i count queries?

Tags:

c++

sqlite

qt

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;
 }
like image 329
Klipnov Avatar asked Apr 10 '26 12:04

Klipnov


1 Answers

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
}
like image 69
hmuelner Avatar answered Apr 13 '26 15:04

hmuelner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!