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

查看:131
本文介绍了如何将包含撇号的语句插入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.

例如:

插入到tbl_insert值('这是Steve的衬衫');

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

How to store this kind of statements in Sqlite database?

应该做什么?

请帮助和建议。

谢谢。

推荐答案

这也是我在SQL Server和MySQL中经历的事情。您绝对应该使用参数化SQL查询

This is something that I go through in SQL Server and MySQL as well. You should definitely use parameterised SQL queries

请参阅此页用于许多语言的示例。

See this page for examples in many languages.

我强烈反对在update语句中使用文字字符串。使用参数化查询。没有理由破坏安全性

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

您可以编写一个函数来替换每个字符实例'''

You can write a function which replaces each instance of character ' with ''

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

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

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