Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Parameter count mismatch on SELECT statement - SQLITE using Bindvalues
Forum Updated to NodeBB v4.3 + New Features

Parameter count mismatch on SELECT statement - SQLITE using Bindvalues

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 720 Views
  • 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.
  • cxamC Offline
    cxamC Offline
    cxam
    wrote on last edited by
    #1

    Hi, I'm currently facing an error where I get "Parameter count mismatch" from query.lastError, my bindvalues are correct (i've tested them).

    My query is:

    QSqlQuery query(DBT);
        query.prepare("SELECT Foto, Nombre, Apellido1, Apellido2, Curso, Grupo, FotoHuella FROM usuarios WHERE Nombre=:nombre1 OR Apellido1=:apellido1 OR Apellido2=:apellido2 OR Curso=:curso1 OR Grupo=:grupo1");
            query.bindValue(":nombre1", nombre);
            query.bindValue(":apellido1", apellido1);
            query.bindValue(":apellido2", apellido2);
            query.bindValue(":curso1", curso);
            query.bindValue(":grupo1", grupo);
        query.exec();
    

    In case you where wondering here is where I set up the database:

    QSqlDatabase DBT=QSqlDatabase::addDatabase("QSQLITE");
        DBT.setDatabaseName("/home/pi/FoodCircleDBT.db");
        DBT.open();
    

    Thanks in advance.

    Stay Hungry, Stay Foolish

    1 Reply Last reply
    0
    • cxamC Offline
      cxamC Offline
      cxam
      wrote on last edited by
      #3

      Allright, I finally figured it out, the problem was the database was corrupt, and i had to create another one manually because if I created the DB with some program it gets corrupted

      Stay Hungry, Stay Foolish

      1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #2

        normally this error is due to a typo in the field names. check the "column" names

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        2
        • cxamC Offline
          cxamC Offline
          cxam
          wrote on last edited by
          #3

          Allright, I finally figured it out, the problem was the database was corrupt, and i had to create another one manually because if I created the DB with some program it gets corrupted

          Stay Hungry, Stay Foolish

          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 Extensions
          • Unsolved