如何在Sqlite数据库中插入包含撇号的语句 [英] How to insert statements that contains apostrophe s into Sqlite database

查看:147
本文介绍了如何在Sqlite数据库中插入包含撇号的语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone应用程式。我使用的是Sqlite数据库。我有一个要求将文本存储在数据库中。文本包含撇号。

In my iPhone app. I am using an Sqlite database. I have a requirement to store the text in database. The text contains apostrophe s.

例如:

into tbl_insert values('It's Steve's Shirt');

如何在Sqlite数据库中存储这种语句?

How to store this kind of statements in Sqlite database?

应该怎么办?

请帮助和建议。

/ p>

Thanks.

推荐答案

这是我在SQL Server和MySQL中经历的。您应该像Ignacio建议的那样使用参数化的SQL查询,或者你必须用''替换

This is something that I go through in SQL Server and MySQL as well. You should either use parameterized SQL queries just as Ignacio suggested OR you have to replace each ' with ''

Insert into tbl_insert values ('It is Steve''s Shirt');

您可以写一个函数,用

http://www.kamath.com/codelibrary/cl003_apostrophe。 asp

但是,我强烈建议不要在update语句中使用文字字符串。使用参数化查询。没有理由危害安全

However I strongly discourage the use of literal strings in the update statement. Use parameterized queries. There's no reason to compromise security

这篇关于如何在Sqlite数据库中插入包含撇号的语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆