QSqlQuery "Parameter count mismatch"
Unsolved
General and Desktop
-
Hi!!.
this error is what i get while i qDebug() the query lastError()
This is how i'm updating my record:QSqlQuery consulta; consulta.prepare("UPDATE tUsuario SET " "rut = ?, nombre = ?, telefono = ?, direccion = ?, email = ?, contrasena = ?" "WHERE REG = 1"); consulta.addBindValue(usuario.get_rut()); consulta.addBindValue(usuario.get_nombre()); consulta.addBindValue(usuario.get_telefono()); consulta.addBindValue(usuario.get_direccion()); consulta.addBindValue(usuario.get_email()); consulta.addBindValue(usuario.get_contrasena()); if (!consulta.exec()) qDebug() << consulta.lastError(); db.close();
I have tried with QSqlQuery::bindValue function too, using the ":parameter" notation with the same result… what do i'm missing?
Note that REG is the primary key autoincrement and unique, so i think i need to exclude in the sql instruction, or not?
Thanks! -
@U7Development said in QSqlQuery "Parameter count mismatch":
"rut = ?, nombre = ?, telefono = ?, direccion = ?, email = ?, contrasena = ?" "WHERE nombre = miNombre");
Missing space character at end of first line or start of second line :) So it's passing
contrasena = ?WHERE nombre = miNombre
-
@U7Development To add to @JonB : you can use https://doc.qt.io/qt-5/qsqlquery.html#executedQuery to see how the query looked like when it was executed, can help to find such issues.