Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. BaseResult::exec: Parameter mismatch
Qt 6.12 LTS is out! See what's new in the release blog

BaseResult::exec: Parameter mismatch

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 4 Posters 9.2k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    You should check last error and query from your model. That might give you more clues about what is happening.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    1
    • V Offline
      V Offline
      Vitaliy WH
      wrote on last edited by
      #5

      QT sent query:
      UPDATE users SET "PASSWD"=? WHERE "users"."ID" = ?
      On request it is visible that parameters are not set
      The question is why?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #6

        Looks like prepared query with anonymous placeholders.

        When exactly is that one called ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • V Offline
          V Offline
          Vitaliy WH
          wrote on last edited by
          #7

          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?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #8

            It's not very clear. Do you mean it happens when you add a new row ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • V Offline
              V Offline
              Vitaliy WH
              wrote on last edited by
              #9
              model->setEditStrategy(QSqlRelationalTableModel::OnRowChange);
              
              1 Reply Last reply
              0
              • V Offline
                V Offline
                Vitaliy WH
                wrote on last edited by
                #10

                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

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  Navodar
                  wrote on last edited by Navodar
                  #11

                  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".

                  jsulmJ 1 Reply Last reply
                  0
                  • N Navodar

                    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".

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #12

                    @Navodar What does http://doc.qt.io/qt-5/qsqlquery.html#executedQuery show?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    N 1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @Navodar What does http://doc.qt.io/qt-5/qsqlquery.html#executedQuery show?

                      N Offline
                      N Offline
                      Navodar
                      wrote on last edited by
                      #13

                      @jsulm here is result of executedQuery():
                      "INSERT INTO MATERIJALI(NAZIV, STANJE_U_SILOSU, ZADNJA_POTROSNJA) VALUES(?, ?, ?)"

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #14

                        What if you use addBindValue rather than bindValue ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • N Offline
                          N Offline
                          Navodar
                          wrote on last edited by
                          #15

                          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

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt
                          • Unsolved