双撇号 [英] Double apostrophes

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

问题描述

我确定这必须是一个简单的修复。我只是想不出来。


为了解决典型的一个问题,我有

acarriername = Replace(txtcarriername.text,"''" ;,'''''")


我的问题是现在插入了2个撇号,而不是一个。对于

的例子,如果有人输入了IT''NICE,当它显示在输入

文本框后面(允许用户更改它)时,它表示这很好。


这是一个sql 2000数据库。


感谢您的帮助。



***通过开发人员指南 http://www.developersdex发送。 com ***

I''m sure this has to be a simple fix. I just cannot figure it out.

To resolve the typical apostrope issue, I have the
acarriername = Replace(txtcarriername.text, "''", "''''")

My problem is that 2 apostrophes are now inserted, instead of one. For
example if someone types in IT''S NICE, when it is displayed in the input
text box later (to allow a user to change it), it says IT''''S NICE.

This is a sql 2000 database.

Thanks for the help.


*** Sent via Developersdex http://www.developersdex.com ***

推荐答案

如何将数据插入数据库?如果您使用

命令对象并将值传递给参数,则不需要执行

替换,因为它是由提供者为您处理的。


你能展示你所有的代码吗?所以我们不必猜测和抓住吸管吗?



乔伊马丁 <乔** @ infosmiths.net>在留言中写道

news:%2 *************** @ tk2msftngp13.phx.gbl ...
How are you inserting the data into the database? If you are using a
command object and passing the values into a parameter, you don''t need to do
the replace since it is handled for you by the provider.

Can you show all of your code so we don''t have to guess and grasp at straws?


"Joey Martin" <jo**@infosmiths.net> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
我是我相信这必须是一个简单的解决方案。我只是想不出来。

为了解决典型的旁路问题,我有
acarriername = Replace(txtcarriername.text,"''","'''' )

我的问题是现在插入了2个撇号,而不是一个。例如,如果有人在IT''NICE中键入,当它稍后显示在输入
文本框中时(允许用户更改它),它就说IT''NICE。

这是一个sql 2000数据库。

感谢您的帮助。


***通过Developersdex发送 http://www.developersdex.com ***
I''m sure this has to be a simple fix. I just cannot figure it out.

To resolve the typical apostrope issue, I have the
acarriername = Replace(txtcarriername.text, "''", "''''")

My problem is that 2 apostrophes are now inserted, instead of one. For
example if someone types in IT''S NICE, when it is displayed in the input
text box later (to allow a user to change it), it says IT''''S NICE.

This is a sql 2000 database.

Thanks for the help.


*** Sent via Developersdex http://www.developersdex.com ***



Joey Martin写道:
Joey Martin wrote:
我确定这必须是一个简单的修复。我只是想不出来。

为了解决典型的旁路问题,我有
acarriername = Replace(txtcarriername.text,"''","'''' )

我的问题是现在插入了2个撇号,而不是一个。例如,如果有人在IT''NICE中输入,当它稍后显示在
输入文本框中(允许用户更改它)时,它表示IT'''S
I''m sure this has to be a simple fix. I just cannot figure it out.

To resolve the typical apostrope issue, I have the
acarriername = Replace(txtcarriername.text, "''", "''''")

My problem is that 2 apostrophes are now inserted, instead of one. For
example if someone types in IT''S NICE, when it is displayed in the
input text box later (to allow a user to change it), it says IT''''S
NICE.



只有在将数据写入数据库时​​才进行替换。不要这样做

任何其他时间。


更好的是,停止使用动态sql。你必须逃避

撇号的唯一原因是因为你没有使用参数。请参阅:

http://groups.google.com/groups?hl=e...tngp13.phx.gbl
http:// groups- beta.google.com/group/...e36562fee7804e
http:// tinyurl.com/jyy0


如果这不能回答你的问题,请发一个简短的repro脚本,这样我们就能看到你的'b $ b'重做。


HTH,

Bob Barrows

-

Microsoft MVP - ASP /ASP.NET

请回复新闻组。我的From

标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。


Only do the replace when writing the data into the database. Do not do it
any other time.

Better yet, stop using dynamic sql. The only reason you have to escape the
apostrophe is because you are not using parameters. See these:

http://groups.google.com/groups?hl=e...tngp13.phx.gbl
http://groups-beta.google.com/group/...e36562fee7804e
http://tinyurl.com/jyy0

If this does not answer your question, post a short repro script so we can
see what you''re doing.

HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don''t check it very often. You will get a
quicker response by posting to the newsgroup.




当前代码:


设置RS = Server.CreateObject(" ADODB.Recordset")

sqlUpdate =" SELECT * FROM ricprops WHERE propno =''" &安培;请求(id)&

"''"


RS.open sqlUpdate,Conn,1,3

RS(评论)=替换(Request.form(" comments),"''","''''')

RS.Update

RS.Close


***通过Developersdex发送 http://www.developersdex.com ***

Current code:

Set RS = Server.CreateObject("ADODB.Recordset")
sqlUpdate = "SELECT * FROM ricprops WHERE propno=''" & Request("id") &
"''"

RS.open sqlUpdate,Conn,1,3
RS("comments") = Replace(Request.form("comments"), "''", "''''")
RS.Update
RS.Close


*** Sent via Developersdex http://www.developersdex.com ***


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

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