开发者

Qt and SQlite Database, How do i count queries?

开发者 https://www.devze.com 2023-03-09 00:16 出处:网络
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.

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 qu开发者_开发技巧ery returns null or empty) 
 {
  do this;
 }
  else 
 {
  do that;
 }


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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消