“问题”和'在文本领域 [英] Problem with " and ' in text field

查看:50
本文介绍了“问题”和'在文本领域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的数据库中,我有两个用户名和''在名称示例中''Doc" Holand或者Al Fiddlin''如果变量是vname并且在将其插入数据库时​​我只使用"和&安培; vname& """除了Al Fiddlin以外,它很好,但是对于Doc有问题。荷兰是这个问题的答案吗?如果是这样我会很感激它是什么。

再次感谢你的帮助

In my data base I have user names with both " and '' in the name example "Doc" Holand or maybe Al Fiddlin'' if the variable is vname and when inserting this into the database I just use the """ & vname & """ it excepts the Al Fiddlin'' just fine but have a problem with the "Doc" Holand is the a answer to this problem? If so I would sure appreciate what it is.
Thanks again for all your help

推荐答案

我的第一个建议是确保你坚持下去使用SQL字符串时使用单一类型的引用。我的偏好和实际标准是使用单引号('')。请参阅引号('')和双引号(") - 在何处以及何时使用它们


一旦您使用了报价类型,您就可以忽略其他类型的问题。 "文件" Holland''处理得非常好,没有任何复杂情况。


包含相同类型报价的值可以简单地加倍。这应该是所有代码中的标准做法:
My first suggestion would be to ensure you stick with a single type of quote when using SQL strings. My preference, and the actual standard, is to use the single-quote (''). See Quotes ('') and Double-Quotes (") - Where and When to use them.

Once you have a quote type in use then you can ignore problems with the other type. ''"Doc" Holland'' is handled perfectly well without any complications.

Values that include the same type of quote can simply be doubled up. This should probably be standard practice in all your code :
展开 | 选择 | Wrap | 行号


好的,没有一个名字同时包含和''。我想改变因为大多数名字已经有单引号,比如Al Feddlin''我发现这很容易在sql语句中使用,只需使用"" &安培; VName& """这工作得很好。我尝试了几种方法来改变单身''但尚未找到答案。谢谢
Ok, none of the names have both the " and ''. I would like to change the " to a '' as most of the name already have the single quote, like the Al Feddlin'' I find that this is easy to use in a sql statement by just using """ & VName & """ and that works just fine. I''ve tried a couple of ways to change the " to a single '' but haven''t found the answer yet. Thanks


我找到了从名称字段中删除双引号的答案。通过使用Chr(34)代替Chr(34)。它就像我想要的那样工作。感谢关于替换声明的建议我之前从未使用过,它会派上用场我很肯定。
I found the answer to removing the double quote from the name field. By using the Chr(34) in place of the " it works just like I wanted it to. Thanks for the suggestion about the replace statement I''ve never used that before and it will come in handy I''m sure.


这篇关于“问题”和'在文本领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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