Maybe it emulates last() using next(). It doesn't say anything about either the database or the ODBC driver that handles it.
Printable View
Maybe it emulates last() using next(). It doesn't say anything about either the database or the ODBC driver that handles it.
Hello, I have a similar problem with an sqlite3 database.
Queries work fine interactively, even queries work fine on the constructor, but on a slot give me this messages on console output:
QSqlQuery::value: not positioned on a valid record
QSqlQuery::value: not positioned on a valid record
QSqlQuery::value: not positioned on a valid record
QSqlQuery::value: not positioned on a valid record
QSqlQuery::value: not positioned on a valid record
I think each message is one for each field in the query string.
The query is executed and the values are retrived, I can use this values without problems, but this messages bothers me, and dirty my console output.
here the implementation of the slot:
Code:
{ qDebug() << id; QSqlQuery queryLoans; queryLoans.prepare("SELECT loan_id, date, value, quotas, cancel_quotas, loan_type FROM tblLOANS WHERE thirdparty_id=:id"); queryLoans.bindValue(":id", id); if (!queryLoans.exec()) loanIdComboBox->clear(); dateEdit->clear(); valueLineEdit->clear(); quotasLineEdit->clear(); cancelQuotasSpinBox->clear(); while (queryLoans.next()) { qDebug() << queryLoans.value(0).toString(); loanIdComboBox->addItem(queryLoans.value(0).toString()); } queryLoans.first(); dateEdit->setDate(queryLoans.value(1).toDate()); valueLineEdit->setText(queryLoans.value(2).toString()); quotasLineEdit->setText(queryLoans.value(3).toString()); loanTypeComboBox->setCurrentIndex(loanTypeComboBox->findText(queryLoans.value(5).toString())); cancelQuotasSpinBox->setValue(queryLoans.value(4).toInt()); }
Do the errors disappear when you comment out lines #20--#25?
Don't dessapear. Even I commented all lines exept the declaration, prepare-bindValue and executed lines of the query, the message still appear.
I repeat, this message appear only in this slot, on the constructor don't appear.
Hello. Now I solved my problem.
The problem is using multiple connections (QObject::connect), the slot avobe call other signal i.e:
Code:
connect(loanIdComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setLoanValues(int)));
loanIdComboBox->clear(); call currentIndexChanged, on that connection I have the same query and for this behavior was the error.
I correct this behavior using at begin of slot loanIdComboBox->blockSignals(true) and then on final of slot loanIdComboBox->blockSignals(false).
DBG is a great help.