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
Forum Updated to NodeBB v4.3 + New Features

Parameter count mismatch on SELECT statement - SQLITE

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 858 Views 2 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.
  • 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, QSql::Out);
            query.bindValue(":apellido1", apellido1, QSql::Out);
            query.bindValue(":apellido2", apellido2, QSql::Out);
            query.bindValue(":curso1", curso, QSql::Out);
            query.bindValue(":grupo1", grupo, QSql::Out);
        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
    • Paul ColbyP Offline
      Paul ColbyP Offline
      Paul Colby
      wrote on last edited by Paul Colby
      #2

      Hi @cxam,

      The problem is that you're specifying QSql::Out - this should be QSql::In which is the default value in the function signature anyway, so you can just leave off the QSql::Out parameter.

      Perhaps the reason you thought to use QSql::Out is that your query is getting (SELECTing) data out of the database, which it is. But the binding itself is providing values into the database query, and so its an input (from the query's perspective), not an output. I hope that makes sense.

      Cheers.

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

        Oh you are right! Thanks a lot!

        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