Hi!
I'm trying to write a string with ' to a table but QSqlQuery returns a syntax error near animateur :
if (!query.
exec("INSERT INTO TEST_DESCRIPTIONS (DESCRIPTION, USER_ID) VALUES('L\'animateur ...',"+QString(id
)+");")) { QMessageBox::critical(nullptr,
"Write Error",
"Failed to save information to database"+error.
text());
}
if (!query.exec("INSERT INTO TEST_DESCRIPTIONS (DESCRIPTION, USER_ID) VALUES('L\'animateur ...',"+QString(id)+");")) {
QSqlError error = query.lastError();
QMessageBox::critical(nullptr, "Write Error", "Failed to save information to database"+error.text());
}
To copy to clipboard, switch view to plain text mode
With MySQL client command line, it insert the row into the table without any problem.
Bookmarks