An error occurred while inserting single quotes in access.

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.