Unsolved BaseResult::exec: Parameter mismatch
-
You should check last error and query from your model. That might give you more clues about what is happening.
-
QT sent query:
UPDATE users SET "PASSWD"=? WHERE "users"."ID" = ?
On request it is visible that parameters are not set
The question is why? -
Looks like prepared query with anonymous placeholders.
When exactly is that one called ?
-
When to we apply changes. In my case, when we move to new row in QTableView, this query sent to server. It turns out, Qt do not fill query parameters. How to solve this problem?
-
It's not very clear. Do you mean it happens when you add a new row ?
-
model->setEditStrategy(QSqlRelationalTableModel::OnRowChange);
-
After changing the line, we go to another line. Changes are sent to the server Firebird. Query we transmitted to server by QSqlRelationalTableModel, but without filling in the parameters. Parameters must fill in QSqlRelationalTableModel, but it does not work for Firebird. With MySQL, there are no such problems.
Sorry for bad English -
I have similar problem:
query.prepare("INSERT INTO MATERIJALI(NAZIV, STANJE_U_SILOSU, ZADNJA_POTROSNJA) VALUES(:naz, :sil, :pot)"); query.bindValue(":naz", ui->eNaziv->text()); query.bindValue(":sil", ui->eStanje->value()); query.bindValue(":pot", ui->eDatum->dateTime().toString());
return: QIBaseResult::exec: Parameter mismatch, expected 0, got 3 parameters
It seems that QIBaseDriver don't support named placeholders. But when I try with positional placeholders, the result is the same:
query.prepare("INSERT INTO MATERIJALI(NAZIV, STANJE_U_SILOSU, ZADNJA_POTROSNJA) VALUES(?, ?, ?)"); query.bindValue(0, ui->eNaziv->text()); query.bindValue(1, ui->eStanje->value()); query.bindValue(2, ui->eDatum->dateTime().toString());
"QIBaseResult::exec: Parameter mismatch, expected 0, got 3 parameters".
-
@Navodar What does http://doc.qt.io/qt-5/qsqlquery.html#executedQuery show?
-
@jsulm here is result of executedQuery():
"INSERT INTO MATERIJALI(NAZIV, STANJE_U_SILOSU, ZADNJA_POTROSNJA) VALUES(?, ?, ?)" -
What if you use addBindValue rather than bindValue ?
-
With:
query.addBindValue(ui->eNaziv->text()); query.addBindValue(ui->eStanje->value()); query.addBindValue(ui->eDatum->dateTime().toString());
result is the same: QIBaseResult::exec: Parameter mismatch, expected 0, got 3 parameters