Re: Insert a double quote into SQL

From: Lin Ma (abc.com)
Date: 08/20/04


Date: Fri, 20 Aug 2004 11:04:49 -0500

Ray,

Thanks for the help. Have a nice day.

Lin Ma

"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:uagogrshEHA.2908@TK2MSFTNGP10.phx.gbl...
> To try to add a little as far as understanding what the problem is, I'll
> paste in an explanation I gave before. This is in regard to your textbox
> values getting truncated. The solution is what Aaron suggested about
> htmlencoding your values.
>
>
> The problem here is simply an HTML problem (but with an ASP solution).
Take
> these lines of HTML:
>
> 1. <input type=text value=Mary's cat said "meow.">
>
> 2. <input type='text' value='Mary's cat said "meow."'>
>
> 3. <input type="text" value="Mary's cat said "meow."">
>
>
> None of those will display what you want.
>
> In number 1, there is no ' or " delimiting the value of the input, so you
> will only see text up until the first space.
> ______
> [Mary's]
> ŻŻŻŻŻŻ
>
> In number 2, ' is the delimiter for the value of the input. So, the first
> time the browser encounters a second ', it will take that to mean the end
of
> the value of the input. Anything after that is just unrecognized markup
> that the browser will ignore. So, you would see:
> ____
> [Mary]
> ŻŻŻŻ
>
> In number 3, " is the delimiter for the value of the input. This time,
the
> first time the browser encounters a " character, it will take that to mean
> the end of the value. So, you'd see:
> ________________
> [Mary's cat said ]
> ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
>
>
> Basically, if you're going to delimit your form values with ", you cannot
> use that character in the value. Or, if you use ' as the delimiter, you
> cannot use ' in the value. I suggest you pick a delimiter and stick with
> it. If you want to follow the "strict" rules that are being phased into
> HTML, X-HTML, or whatever, you should select the " as your value
delimiter.
>
>
>
> Ray at work
>
>
> "Lin Ma" <abc.com> wrote in message
> news:eA5StcshEHA.2764@TK2MSFTNGP11.phx.gbl...
> > Thank Aaron.
> >
> > It did go to the SQL DB when I add an extra double quote.
> >
> > But the problem is when I retrive the data with double quote value and
> > insert into a <input > field, the quote is gone.
> >
> > Example:
> > Field ToPartDescription value = something with double quote" value
> >
> > My input field value will trim the " and everything after the "
> >
> > <input name="ToPartDescription" size="30" class="Inputbox" value="<%=
> > rs("ToPartDescription") %>">
> > It will display only: something with doubel quote
> >
> > Any idea to fix this?
> >
> > Thanks,
> >
> >
> > "Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
> > news:ekcbdNshEHA.712@TK2MSFTNGP09.phx.gbl...
> >> ASP sees " as the end of the string. So, double it up.
> >> http://www.aspfaq.com/2065
> >>
> >> And stop using a recordset to affect data!
> >> http://www.aspfaq.com/2191
> >>
> >> connectionObject.execute "UPDATE mytable SET name='my name""' WHERE id
=
> >> 100", , 129
> >>
> >> --
> >> http://www.aspfaq.com/
> >> (Reverse address to reply.)
> >>
> >>
> >>
> >>
> >> "Lin Ma" <abc.com> wrote in message
> >> news:#IKrHCshEHA.3348@TK2MSFTNGP12.phx.gbl...
> >> > Hello,
> >> >
> >> > I am trying to insert/update a field with double quote " . But SQL
> >> database
> >> > will not take it.
> >> >
> >> > Anyone have a solution? Thanks,
> >> >
> >> > ----------------------
> >> >
> >> > set rs= Server.CreateObject("ADODB.Recordset")
> >> >
> >> >
> >> > rs.open "update mytable set name= ' my name" ' where id= 100 ",
> >> strDocCon
> >> >
> >> >
> >>
> >>
> >
> >
>
>



Relevant Pages

  • Re: Truncated string (still)
    ... > time the browser encounters a second ', it will take that to mean the end ... > use that character in the value. ... Or, if you use ' as the delimiter, you ... I will use the phrase Ray did use in his ...
    (microsoft.public.inetserver.asp.db)
  • Re: Truncated string (still)
    ... The problem here is simply an HTML problem. ... ' is the delimiter for the value of the input. ... first time the browser encounters a " character, it will take that to mean ... I will use the phrase Ray did use in his ...
    (microsoft.public.inetserver.asp.db)
  • Re: Insert a double quote into SQL
    ... The problem here is simply an HTML problem. ... ' is the delimiter for the value of the input. ... first time the browser encounters a " character, it will take that to mean ... > It did go to the SQL DB when I add an extra double quote. ...
    (microsoft.public.inetserver.asp.db)
  • Re: ADO Recordset FIND problem
    ... That is the only character that can be confused with a string ... Keep in mind, if you use a double quote as a string delimiter, ...
    (microsoft.public.scripting.vbscript)
  • Re: FindFirst fails on indexed field
    ... problem with the FindFirst method. ... was purely an example so replacing the double quote is not a solution. ... The first uses a single quote delimiter, ... delimiter and since a double quote does occur in the search string it ...
    (comp.databases.ms-access)

Loading