Http://blog.sina.com.cn/s/blog_4d12b0680100txle.html
When I published an article today, I found that my website failed to publish the article. Later I ruled out it one by one because I didn't translate the single quotes and it was wrong when inserting access.
It is normal to have single quotes in the text, so this problem can only be fixed. The method is actually very simple, because access can use two single quotes for translation, therefore, you only need to replace the single quotation marks in the text with double quotation marks.
Code:
String strcontent = This. fckeditor1.value;
Strcontent = strcontent. Trim (). Replace ("'","''");
After modification, the insert operation is successful.
In SQL, insert into yourtable (F1, F2) values (100, 'abc ')
String data is enclosed in single quotes. If the inserted data contains a single
You can replace single quotes with two single quotes.
Two single quotes in a row indicate a single quotes character, for example
Insert into yourtable (F1, F2) values (100, 'AB' 'C') indicates insertion
The F2 field of the new record is AB 'c.
You can use the replace function to implement this function:
Replace (yourstr ,"'","''")
In. net, you must first check whether there are single quotes in the input data. If so, you must automatically change one single quotes to two single quotes.