Parameter count mismatch on SELECT statement - SQLITE using Bindvalues

  • 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);

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

    QSqlDatabase DBT=QSqlDatabase::addDatabase("QSQLITE");

    Thanks in advance.

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

  • 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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.