[SOLVED]Parameter count mismatch
-
Hi. I've got this error message("Parameter count mismatch") at runtime. Here is my code.
@
void SqlHandler::signup(const QString & name, const QString & pass, const QChar & sexe){
QSqlQuery query(db);
if(!query.exec(QString("SELECT id_user FROMUser
WHERE pseudo LIKE "%1" AND pass LIKE "%2"").arg(name).arg(pass)))
qDebug() << query.lastError();
else{
if(query.size() > 0){
emit doublon();
}else{
query.prepare("INSERT INTOUser
VALUES (?,?,?,?,?)");
query.bindValue(0,name);
query.bindValue(1,pass);
query.bindValue(2,sexe);
query.bindValue(3,0);
query.bindValue(4,QString());
if(!query.exec())
qDebug() << query.lastError().text() ;//BOOM here
else
emit signupSuccess();
}
}
}
@Here is the User table scheme:
User
(id_user
serial(11) NOT NULL,pseudo
varchar(20) NOT NULL,pass
varchar(20) NOT NULL,ip
varchar(15) NOT NULL,status
tinyint(1) NOT NULL,group
int(11) DEFAULT NULL, PRIMARY KEY (id_user
));
I'm using QSQLITE.
Thanks -
You have to check the lastError isValid bit first:
@if
(query.lastError().isValid())
qDebug() << query.lastError();
@
If no error occurred it fails.
greetz -
It didn t work. But i've solved the problem. The sql for creating the User table should be
@
CREATE TABLEUser
(id_user
INTEGER NOT NULL,pseudo
varchar(20) NOT NULL,pass
varchar(20) NOT NULL,sexe
char(1) NOT NULL,ip
varchar(15) NOT NULL,status
tinyint(1) NOT NULL,group
int(11) DEFAULT NULL, PRIMARY KEY (id_user
));
@
Thx