Parameter count mismatch
Unsolved
Qt Creator and other tools
-
I wrote this code and i got an error "Parameter count mismatch", btw, I connect successfully to the database. how to solve it?
this is the code :db = QSqlDatabase::addDatabase("QSQLITE"); //this is the driver for SQL Lite db.setPort(3306); db.setHostName("sql2.freemysqlhosting.net"); db.setPassword("*****"); db.setUserName("sql2****"); if(!db.open()) ui->label->setText("<font color='red'>Failed to connect to database.</font>"); else ui->label->setText("<font color='green'>Connected to database and Opened.</font>"); qsr.prepare("INSERT INTO mytab(machine_id, operator_id) VALUES(?,?);"); qsr.addBindValue(ui->lineEdit->text()); qsr.addBindValue(ui->lineEdit_Operator_ID->text()); if(qsr.exec()) QMessageBox::information(this, "State","Saved",QMessageBox::Ok); else QMessageBox::information(this, "State", qsr.lastError().text(),QMessageBox::Ok);
-
@Designer23 said in Parameter count mismatch:
"Parameter count mismatch"
SQLite shows this error for basically any error that occurs :-( Syntax, parameter count, parameter types - all kinds of things can trigger it.
Are
machine_id
andoperator_id
really strings, not integers? -
@Designer23
Show the definition (including columns) of tablemytab
.