PDA

View Full Version : QODBC addBindValue error



jonman364
2nd July 2008, 21:21
When adding a customer to the database, all works as expected. But when I am updating customer information, I get an error like "ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 3." (this is not the exact error). This error popped up when I switch from an SQLite database to an Access database.

Can anybody tell what my problem might be?



void CustomerInfo::accept(){
QSqlQuery q;
if(custId < 1)
q.prepare("INSERT INTO customer (name, dept) VALUES(?, ?)");
else
q.prepare(QString("UPDATE customer SET name = ?, dept = ? WHERE custId = %1").arg(custId));
q.addBindValue(ui.leName->text());
q.addBindValue(ui.leDept->text());
if(q.exec())
setResult(QDialog::Accepted);
else{
setResult(QDialog::Rejected);
QMessageBox::information(this, "", q.lastQuery() + "\n" + q.lastError().text());
}
hide();
}