LaurentDuroisin
21st December 2015, 13:06
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)+");")) {
QSqlError error = query.lastError();
QMessageBox::critical(nullptr, "Write Error", "Failed to save information to database"+error.text());
}
With MySQL client command line, it insert the row into the table without any problem.
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)+");")) {
QSqlError error = query.lastError();
QMessageBox::critical(nullptr, "Write Error", "Failed to save information to database"+error.text());
}
With MySQL client command line, it insert the row into the table without any problem.