[Qt-interest] mqsql query terminating at 100th result
Tony Rietwyk
tony.rietwyk at rightsoft.com.au
Wed Feb 3 02:24:26 CET 2010
Hi Robert,
I have used QSqlQuery.exec("select * from ....") without any problems on the
IBASE driver. Your problem sounds like an error in the cache handling of
your driver (was it SQLLITE?). Suggestions:
- Use QSqlQuery, instead of QSqlQueryModel.
- Use QSqlQuery setForwardOnly to disable the caching.
- Use a separate query "select count(*) from ...." to get the rowcount,
instead of query.size.
Hope that helps,
Tony.
> -----Original Message-----
> Folks,
>
> I am taking some baby steps into knocking up a fairly simply database
> front end. I have a load of tables created in knoda and I can happily
> connect to the database and open and examine all the tables.
>
> However, when the tables are greater than 99 rows, even though the
> query.size() returns the correct number of rows, the
> query.next() just
> terminates at the 100th entry.
>
> My code is here:
>
> queryString = "SELECT * FROM " +
> ui->tablesComboBox->currentText();
> query.exec(queryString);
> rows = query.size();
>
> line = 0;
> while(query.next())
> {
> pos = query.at();
> line++;
> ui->tableWidget->insertRow(pos);
> queryString = "";
> for (j=0;j<columns;j++)
> {
> queryString = query.value(j).toString();
> QTableWidgetItem *qTItem = new QTableWidgetItem;
> qTItem->setText(queryString);
>
> ui->tableWidget->setItem(line,j,qTItem);
> }
> line++;
> }
>
> This fills up my table very nicely in terms of reading all
> the values in
> all the columns until I hit line 100 where the while
> (query.next()) loop
> exits. I get pos returning 4,294,967,294 in qt creator, which
> is -2, the
> result for the end of table I think. What I find odd is that the line:
>
> rows = query.size();
>
> Does give figures much greater than 99 reflecting te real size of the
> table.
>
> Can any one shed any light on this please?
>
> Many thanks!
More information about the Qt-interest-old
mailing list