I have a table with 16 columns. I perform a SELECT
using the QSqlQuery
class. I get two rows as expected, but only the first 2 columns out of the 16.
Here is a simplified version of the query
QSqlQuery query(f_db);
query.prepare(QString("SELECT * FROM my_table WHERE status = 'good'");
query.exec();
query.next();
int const max(query.size()); // here max == 2 instead of 16
for(int idx(0); idx < max; ++idx)
{
QVariant v(it->second->value(idx));
...v is correct for column 1 and 2...
}
Any idea why MySQL would not return all 16 columns.
Depending to this article you are getting number of rows not number of columns, query.size()
returning the number of records. however query.record().count
returning the number of columns