Strange behaviour of QSqlQuery
-
As the other queries work, this messages seems to be misleading.
I suggest to look at the QString for your query by using qDebug().
Probably this may be useful for you:
@
QString s = "INSERT INTO [dbo].[Pesee] ...";
query.prepare(s);
if (!query.exec()) {
QMessageBox::warning(this, "ERR", "Error in query!\n" + query.lastError().text(), QMessageBox::Ok);
qDebug() << s;@
-
That's not that finally -_-
I test the call of this query in a basic program and it work.
Actually, I just saw that in my original program, two of the arguments are null (= 0) and can't work because of the relation with other table I guess...
I'll fix it before anything else and see what happen after that.Thanks anyway ^^
-
I use it like this:
@
query = QSqlQuery(db);
QString s = "UPDATE mytable SET\n"
"field1 = :p01, field2 = :p02\n"
"WHERE fieldidx = :pID;";
query.prepare(s);
// WHERE clause:
query.bindValue(":pID", ui->lineEditID->text());
// SET fields:
query.bindValue(":p01", ui->lineEdit01->text());
query.bindValue(":p02", ui->lineEdit02->text());if (!query.exec()) {
// show lastError:
qDebug() << query.lastError();
// show QString of query:
qDebug() << s;
}
@