I have encountered a problem. When testing the editing of information, if the edited content contains a single quote ('), it will fail to be written to the MySQL database. Use the following code to print the error: if (!this->m_sql_query.prepare(update_string)) { printf("exec fail—>%s\n", this->m_sql_query.lastError().text().toStdString().c_str()); } if (!this->m_sql_query.exec()) { printf("exec fail—>%s\n", this->m_sql_query.lastError().text().toStdString().c_str()); } The printed result is: Please refer to the following relevant information: After analysis, it was found that the string in the inserted content was truncated at the single quotes when editing the SQL statement, resulting in a syntax error. Solution : Replace the characters containing single quotes (') with (''). SQL uses two single quotes instead of one single quote. This is the end of this article about the in-depth explanation of the problem of failure to write English single quotes "'" in SQL. For more related content about failure to write English single quotes "'" in SQL, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Docker Machine in-depth explanation
>>: Some points on using standard HTML codes in web page creation
1. First, generate the public key and private key...
Ellipses appear when multi-line text overflows Th...
Each of these 16 sites is worth reading carefully,...
Log in docker login Complete the registration and...
Startups often bring us surprises with their unco...
1) Enter the folder path where the jdk file is st...
Data sorting asc, desc 1. Single field sorting or...
Basic Concepts By default, Compose creates a netw...
Table of contents 1. Shallow copy 1. Object.assig...
Table of contents need: Main points: According to...
Table of contents Brief Analysis of MySQL Master-...
Table of contents Case scenario Solving the probl...
This question is a discussion among netizens in a...
The frame and rules attributes of the table tag c...
When implementing this function, the method I bor...