mercredi 22 avril 2015

How to get total number of rows/records in an sqlite table

i want to know how to get the total number of rows/records in an sqlite table and assign it to a variable. I did this;

    QSqlQuery query("SELECT COUNT(*) FROM class1_bills");

But the problem is, how do i assign the result to a variable? I tried;

int rows = query.seek(0);

and;

int rows = query.value(0).toInt();

Yes, I know doing that accesses just the record at field position 0 in the table. But it seems Qt's query methods are for accessing particular records at field positions only. If i'm wrong please correct me. So how do i get the total row count in the table?

Aucun commentaire:

Enregistrer un commentaire