开发者

Replace single quote in insert query

开发者 https://www.devze.com 2023-03-26 03:05 出处:网络
I am working in SQLite database for Iphone App.In Objecitve my following query is getting failed because of the value \"This is user\'s profile\" as it contains single quote.

I am working in SQLite database for Iphone App.In Objecitve my following query is getting failed because of the value "This is user's profile" as it contains single quote.

INSERT INTO TEST(Code,Desc) VALUES开发者_运维知识库('Test','This is user's profile')

Because of the String my insert query is going failed.

Please suggest a solution

Thanks, Shradha harne


Oddly, to escape single quotes you have to add an other single quite 'This is a user''s profile'


Replace occurrence of ' with '' in your string and pass the value to your query,
i.e. INSERT INTO TEST(Code,Desc) VALUES('Test','This is user''s profile')


You could try to double the apostrophe sign in your text (i.e. '' instead of ').

0

精彩评论

暂无评论...
验证码 换一张
取 消