插入表格时单引号 [英] single quotes while inserting in Table

查看:88
本文介绍了插入表格时单引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我有一点怀疑。当用户在文本字段中输入'(单引号)时。

插入表格时,它会给我们错误。

但我在少数网站看到过 - Facebook,CodeProject,他们允许'(单引号)并显示相同。

任何人都可以指导我。

Dear Friends,

I have small doubt. When user enters the ' (single quotes) in the text field.
While inserting in Table, it give us the error.
But I have seen in few sites eg- Facebook, CodeProject where they allow ' (single quotes) and display the same.
Can anyone guide me on this.

推荐答案





如果你想在sql server中添加'(撇号),那么应该是这样的



INSERT INTO exampleTbl VALUES('希望这适合你 - R '' K');



输出将是

希望这适合你 - R ' K



添加两个撇号(')如果你想加一个。



希望这对你有所帮助。



问候,

RK
Hi,

If you want to add '(apostrophe) in sql server, then it should be like this

INSERT INTO exampleTbl VALUES('Hope this works for you - R''K');

Output will be
Hope this works for you - R'K

Add two apostrophe(') if you want to add one.

Hope this helps you a bit.

Regards,
RK


在提交时,使用类似的代码:



On the submit, use a bit of code that is like this:

replace(TEXTBOXNAME, "'", "''")





当然,更好的选择是使用存储过程和参数,因此无需担心!!



Of course, a better option would be to use a stored procedure and parameter, thus not needing to worry about it!!


这篇关于插入表格时单引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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