quotation marks in text fields

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default quotation marks in text fields

    I'm using an sql INSERT statement to add text data to an Access database. If
    the text includes an embedded quotation mark, the text is truncated at that
    point - without an error. This only happens when I am hosted on Windows 2003
    sever. When hosted on Windows 2000 it works fine.

    Is there something similar to using the Replace function to add a 2nd
    apostrophe (eg: Replace(textstream,"'","''") to avoid errors with embedded
    apostrophes?

    Thanks, Steve G.


    SteveG Guest

  2. Similar Questions and Discussions

    1. anybody getting quotation marks
      so every time i attempt to install flash 8, it prompts me if i want to run activeX controls, i click yes, i see the green/red/blue square for a...
    2. CFSET and Quotation Marks
      I have a page that generates an html attachment and sends it in email to an admin. The page is an asp page. my problem is that the asp page code...
    3. Tyogrpaher's Quotation Marks?
      Is there a way to get typographer's or "smart" quotes to display in Fireworks? I've yet to find how to do this. I'm running OSX and FireWorks MX....
    4. Quotation marks in match fields screw up import
      For fun, several friends and I constructed an elaborate FileMaker Pro database containing all songs to reach the Billboard Top 40 charts (and many...
    5. Quotation marks
      How can I make correct quotation marks insted of inches?
  3. #2

    Default Re: quotation marks in text fields

    Yes, exactly what you're getting at. To "escape" apostrophes in SQL, you
    double them.


    sData = Request.Form("textfield")
    sSQL = "INSERT INTO myTable (col) VALUES ('" & Replace(sData, "'", "''") &
    "')"

    Ray at home

    "SteveG" <steveg1@tampabay.rr.com> wrote in message
    news:LanFc.15752$IX4.1289343@twister.tampabay.rr.c om...
    > I'm using an sql INSERT statement to add text data to an Access database.
    If
    > the text includes an embedded quotation mark, the text is truncated at
    that
    > point - without an error. This only happens when I am hosted on Windows
    2003
    > sever. When hosted on Windows 2000 it works fine.
    >
    > Is there something similar to using the Replace function to add a 2nd
    > apostrophe (eg: Replace(textstream,"'","''") to avoid errors with embedded
    > apostrophes?
    >
    > Thanks, Steve G.
    >
    >

    Ray at Guest

  4. #3

    Default Re: quotation marks in text fields

    SteveG wrote:
    > I'm using an sql INSERT statement to add text data to an Access
    > database. If the text includes an embedded quotation mark, the text
    > is truncated at that point - without an error. This only happens when
    > I am hosted on Windows 2003 sever. When hosted on Windows 2000 it
    > works fine.
    Really? Delimiter problems should not depend on the OS being used ...
    >
    > Is there something similar to using the Replace function to add a 2nd
    > apostrophe (eg: Replace(textstream,"'","''") to avoid errors with
    > embedded apostrophes?
    >
    > Thanks, Steve G.
    Switch to using saved parameter queries and never worry about delimiters
    again. Just Google for posts by me containing those words for details.

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] Guest

  5. #4

    Default Re: quotation marks in text fields

    Bob,

    Thanks for the response. I've never used QueryDef or saved parameter
    queries. I've now read most of the related articles on google and am still
    unsure how to code it in ASP. M/S KBase article # 142938 comes closest but I
    don't think the example is for ASP. Can you point me to a KB article or one
    of yours that might help?

    Steve G.
    "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:%23nKtKRPYEHA.1224@TK2MSFTNGP09.phx.gbl...
    > SteveG wrote:
    > > I'm using an sql INSERT statement to add text data to an Access
    > > database. If the text includes an embedded quotation mark, the text
    > > is truncated at that point - without an error. This only happens when
    > > I am hosted on Windows 2003 sever. When hosted on Windows 2000 it
    > > works fine.
    >
    > Really? Delimiter problems should not depend on the OS being used ...
    >
    > >
    > > Is there something similar to using the Replace function to add a 2nd
    > > apostrophe (eg: Replace(textstream,"'","''") to avoid errors with
    > > embedded apostrophes?
    > >
    > > Thanks, Steve G.
    >
    > Switch to using saved parameter queries and never worry about delimiters
    > again. Just Google for posts by me containing those words for details.
    >
    > Bob Barrows
    >
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >
    >

    SteveG Guest

  6. #5

    Default Re: quotation marks in text fields

    Several of these posts include instructions on how to run the queries from
    ASP.

    [url]http://www.google.com/groups?as_q=saved%20parameter%20query&safe=images& ie=UTF-8&as_uauthors=Bob%20Barrows&lr=&hl=en[/url]

    Bob Barrows

    SteveG wrote:
    > Bob,
    >
    > Thanks for the response. I've never used QueryDef or saved parameter
    > queries. I've now read most of the related articles on google and am
    > still unsure how to code it in ASP. M/S KBase article # 142938 comes
    > closest but I don't think the example is for ASP. Can you point me
    > to a KB article or one of yours that might help?
    >
    > Steve G.
    > "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    > news:%23nKtKRPYEHA.1224@TK2MSFTNGP09.phx.gbl...
    >> SteveG wrote:
    >>> I'm using an sql INSERT statement to add text data to an Access
    >>> database. If the text includes an embedded quotation mark, the text
    >>> is truncated at that point - without an error. This only happens
    >>> when
    >>> I am hosted on Windows 2003 sever. When hosted on Windows 2000 it
    >>> works fine.
    >>
    >> Really? Delimiter problems should not depend on the OS being used ...
    >>
    >>>
    >>> Is there something similar to using the Replace function to add a
    >>> 2nd apostrophe (eg: Replace(textstream,"'","''") to avoid errors
    >>> with embedded apostrophes?
    >>>
    >>> Thanks, Steve G.
    >>
    >> Switch to using saved parameter queries and never worry about
    >> delimiters again. Just Google for posts by me containing those words
    >> for details.
    >>
    >> Bob Barrows
    >>
    >> --
    >> Microsoft MVP - ASP/ASP.NET
    >> Please reply to the newsgroup. This email account is my spam trap so
    >> I don't check it very often. If you must reply off-line, then remove
    >> the "NO SPAM"
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] Guest

  7. #6

    Default Re: quotation marks in text fields

    Bob,

    Those were excellent. Once I found one that explained that they were plain
    ol' Access queries with parameters, I was off and running. They are really
    easier once you understand them. The good news is that they work, the bad
    new is I still have my problem. I should have paid more heed to your
    original questioning of a Win 2003 problem. Turns out that the data
    truncation is occurring while passing hidden form fields from one page to
    another. I take the form input in on one page, display the data on a 2nd
    page and then pass it to a 3rd page (via hidden form fields) where I then
    write it to the database. I've now proven the data is good leaving the 2nd
    page (response.write) and truncated upon receipt in the 3rd. If I bypass the
    display step and
    avoid passisng the data via hidden form fields - all works fine, in fact
    really fine now that I'm using parameter queries!. Any suggestions?

    Steve G.
    "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:eBmWfvbYEHA.732@TK2MSFTNGP10.phx.gbl...
    > Several of these posts include instructions on how to run the queries from
    > ASP.
    >
    >
    [url]http://www.google.com/groups?as_q=saved%20parameter%20query&safe=images& ie=UTF-8&as_uauthors=Bob%20Barrows&lr=&hl=en[/url]
    >
    > Bob Barrows
    >
    > SteveG wrote:
    > > Bob,
    > >
    > > Thanks for the response. I've never used QueryDef or saved parameter
    > > queries. I've now read most of the related articles on google and am
    > > still unsure how to code it in ASP. M/S KBase article # 142938 comes
    > > closest but I don't think the example is for ASP. Can you point me
    > > to a KB article or one of yours that might help?
    > >
    > > Steve G.
    > > "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    > > news:%23nKtKRPYEHA.1224@TK2MSFTNGP09.phx.gbl...
    > >> SteveG wrote:
    > >>> I'm using an sql INSERT statement to add text data to an Access
    > >>> database. If the text includes an embedded quotation mark, the text
    > >>> is truncated at that point - without an error. This only happens
    > >>> when
    > >>> I am hosted on Windows 2003 sever. When hosted on Windows 2000 it
    > >>> works fine.
    > >>
    > >> Really? Delimiter problems should not depend on the OS being used ...
    > >>
    > >>>
    > >>> Is there something similar to using the Replace function to add a
    > >>> 2nd apostrophe (eg: Replace(textstream,"'","''") to avoid errors
    > >>> with embedded apostrophes?
    > >>>
    > >>> Thanks, Steve G.
    > >>
    > >> Switch to using saved parameter queries and never worry about
    > >> delimiters again. Just Google for posts by me containing those words
    > >> for details.
    > >>
    > >> Bob Barrows
    > >>
    > >> --
    > >> Microsoft MVP - ASP/ASP.NET
    > >> Please reply to the newsgroup. This email account is my spam trap so
    > >> I don't check it very often. If you must reply off-line, then remove
    > >> the "NO SPAM"
    >
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >
    >


    SteveG Guest

  8. #7

    Default Re: quotation marks in text fields

    SteveG wrote:
    > Bob,
    >
    > Those were excellent. Once I found one that explained that they were
    > plain
    > ol' Access queries with parameters, I was off and running. They are
    > really
    > easier once you understand them. The good news is that they work,
    > the bad
    > new is I still have my problem. I should have paid more heed to your
    > original questioning of a Win 2003 problem. Turns out that the data
    > truncation is occurring while passing hidden form fields from one
    > page to
    > another. I take the form input in on one page, display the data on a
    > 2nd
    > page and then pass it to a 3rd page (via hidden form fields) where I
    > then
    > write it to the database. I've now proven the data is good leaving
    > the 2nd
    > page (response.write) and truncated upon receipt in the 3rd. If I
    > bypass the
    > display step and
    > avoid passisng the data via hidden form fields - all works fine, in
    > fact
    > really fine now that I'm using parameter queries!. Any suggestions?
    >
    I guess we need to see what the code looks like in page two. What's wrong
    with using both hidden fields and display fields?

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] Guest

  9. #8

    Default Re: quotation marks in text fields

    Bob,
    Here is the code from Page 2 . I left out the display tables above this form

    <form method="POST" action="ProcessOrder.asp">
    <p align="center"> If you want to make changes to your input, press the
    [BACK] button on your Browser.</p><br>
    Press &quot;Proceed&quot; when you are satisfied with your Gripe-O-Gram
    <br>
    and you are ready to proceed with payment <br>
    <input type="submit" value="Proceed" name="B1">
    <input type="hidden" name="fName" value="<%= Request.Form("Name") %>">
    <input type="hidden" name="fEmail" value="<%= Request.Form("Email") %>">
    <input type="hidden" name="fToName" value="<%= Request.form("ToName") %>">
    <input type="hidden" name="fToAdr" value="<%= Request.Form("ToAdr") %>">
    <input type="hidden" name="fToCity" value="<%= Request.Form("ToCity") %>">
    <input type="hidden" name="fToState" value="<%= Request.Form("ToState")
    %>">
    <input type="hidden" name="fToZip" value="<%= Request.Form("ToZip") %>">
    <input type="hidden" name="fGriperName" value="<%=
    Request.Form("GriperName") %>">
    <input type="hidden" name="fGripeeName" value="<%=
    Request.Form("GripeeName") %>">
    <input type="hidden" name="fAdj" value="<%= Request.Form("Adjective") %>">
    <input type="hidden" name="fMod" value="<%= Request.Form("Modifier") %>">
    <input type="hidden" name="fNoun" value="<%= Request.Form("Noun") %>">
    <input type="hidden" name="fGripeText" value="<%=
    Request.Form("GripeText") %>">
    </form>
    <%= Request.form("Name")%>

    Previous stmt gives this GOOD html result:
    Billy "The Wonder Man" Graham

    -------------------------------------------------------
    Page 3 ("ProcessOrder.asp") code:
    Dim fControlNum
    Dim fName
    Dim fEmail
    Dim fToName
    Dim fToAdr
    Dim fToCity
    Dim fToState
    Dim fToZip
    Dim fGriperName
    Dim fGripeeName
    Dim fAdj
    Dim fMod
    Dim fNoun
    Dim fGripeText
    Dim rsGripes
    '== Create a random Control Number
    Randomize
    fControlNum = Round((Rnd *1000001)+1,0) 'results between 0&1, x1M +1, round
    to 0 decimals
    '== Put the form fields into variables in preparation for use in sql
    Response.write(Request.Form("fName"))
    fName = Replace(Request.Form("fName"),"'","''")
    fEmail = Replace(Request.Form("fEmail"),"'","''")
    fToName = Replace(Request.Form("fToName"),"'","''")
    fToAdr = Replace(Request.Form("fToAdr"),"'","''")
    fToCity = Replace(Request.Form("fToCity"),"'","''")
    fToState = Replace(Request.Form("fToState"),"'","''")
    fToZip = Request.Form("fToZip")
    fGriperName = Replace(Request.Form("fGriperName"),"'","''")
    fGripeeName = Replace(Request.Form("fGripeeName"),"'","''")
    fAdj = Request.Form("fAdj")
    fMod = Request.Form("fMod")
    fNoun = Request.Form("fNoun")
    fGripeText = Replace(Request.Form("fGripeText"),"'","''")
    ......followed by database processing......

    Html results from Response.Write (14 lines back/above) gives truncated
    result:
    Billy

    Anything obvious I'm doing wrong to cause this?
    Really appreciate your help & follow-thru. Steve G.


    "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:%23UTlpAuYEHA.3512@TK2MSFTNGP12.phx.gbl...
    > SteveG wrote:
    > > Bob,
    > >
    > > Those were excellent. Once I found one that explained that they were
    > > plain
    > > ol' Access queries with parameters, I was off and running. They are
    > > really
    > > easier once you understand them. The good news is that they work,
    > > the bad
    > > new is I still have my problem. I should have paid more heed to your
    > > original questioning of a Win 2003 problem. Turns out that the data
    > > truncation is occurring while passing hidden form fields from one
    > > page to
    > > another. I take the form input in on one page, display the data on a
    > > 2nd
    > > page and then pass it to a 3rd page (via hidden form fields) where I
    > > then
    > > write it to the database. I've now proven the data is good leaving
    > > the 2nd
    > > page (response.write) and truncated upon receipt in the 3rd. If I
    > > bypass the
    > > display step and
    > > avoid passisng the data via hidden form fields - all works fine, in
    > > fact
    > > really fine now that I'm using parameter queries!. Any suggestions?
    > >
    > I guess we need to see what the code looks like in page two. What's wrong
    > with using both hidden fields and display fields?
    >
    > Bob Barrows
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >
    >

    SteveG Guest

  10. #9

    Default Re: quotation marks in text fields

    Before I attempt to reproduce this with my web server, let me ask if you've
    tried HTMLEncode when purring the data inot the hidden fields?

    <input type="hidden" name="fName" value="
    <%= Server.HTMLEncode(Request.Form("Name")) %>">

    Bob Barrows


    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] Guest

  11. #10

    Default Re: quotation marks in text fields

    It Works . No truncation using the HTMLencode.
    Why do I need it? I'll be researching in parallel.

    Steve G
    "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:OhZYqBwYEHA.3972@TK2MSFTNGP12.phx.gbl...
    > Before I attempt to reproduce this with my web server, let me ask if
    you've
    > tried HTMLEncode when purring the data inot the hidden fields?
    >
    > <input type="hidden" name="fName" value="
    > <%= Server.HTMLEncode(Request.Form("Name")) %>">
    >
    > Bob Barrows
    >
    >
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >
    >

    SteveG Guest

  12. #11

    Default Re: quotation marks in text fields

    Think about what happens when your data contains quotes:
    <input type="hidden" name="fName" value="some data that "contains
    some quotes"">

    Where does the parser think the sting being assigned to the value attribute
    ends?

    Now look at the result of HTMLEncode:
    <input type="hidden" name="fName" value="some data that &quot;contains
    some quotes&quot;">

    There is no problem deciding where this string ends, right?

    Bob Barrows

    SteveG wrote:
    > It Works . No truncation using the HTMLencode.
    > Why do I need it? I'll be researching in parallel.
    >
    > Steve G
    > "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    > news:OhZYqBwYEHA.3972@TK2MSFTNGP12.phx.gbl...
    >> Before I attempt to reproduce this with my web server, let me ask if
    >> you've tried HTMLEncode when purring the data inot the hidden fields?
    >>
    >> <input type="hidden" name="fName" value="
    >> <%= Server.HTMLEncode(Request.Form("Name")) %>">
    >>
    --
    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.


    Bob Barrows [MVP] Guest

  13. #12

    Default Re: quotation marks in text fields

    Agreed - but why do I need it on this site and not others? Steve G.
    "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:u35llj1YEHA.3688@TK2MSFTNGP12.phx.gbl...
    > Think about what happens when your data contains quotes:
    > <input type="hidden" name="fName" value="some data that "contains
    > some quotes"">
    >
    > Where does the parser think the sting being assigned to the value
    attribute
    > ends?
    >
    > Now look at the result of HTMLEncode:
    > <input type="hidden" name="fName" value="some data that &quot;contains
    > some quotes&quot;">
    >
    > There is no problem deciding where this string ends, right?
    >
    > Bob Barrows
    >
    > SteveG wrote:
    > > It Works . No truncation using the HTMLencode.
    > > Why do I need it? I'll be researching in parallel.
    > >
    > > Steve G
    > > "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    > > news:OhZYqBwYEHA.3972@TK2MSFTNGP12.phx.gbl...
    > >> Before I attempt to reproduce this with my web server, let me ask if
    > >> you've tried HTMLEncode when purring the data inot the hidden fields?
    > >>
    > >> <input type="hidden" name="fName" value="
    > >> <%= Server.HTMLEncode(Request.Form("Name")) %>">
    > >>
    >
    > --
    > 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.
    >
    >
    >

    SteveG Guest

  14. #13

    Default Re: quotation marks in text fields

    I do not know. It should not be site-specific.

    Bob
    SteveG wrote:
    > Agreed - but why do I need it on this site and not others? Steve G.
    > "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    > news:u35llj1YEHA.3688@TK2MSFTNGP12.phx.gbl...
    >> Think about what happens when your data contains quotes:
    >> <input type="hidden" name="fName" value="some data that "contains
    >> some quotes"">
    >>
    >> Where does the parser think the sting being assigned to the value
    >> attribute ends?
    >>
    >> Now look at the result of HTMLEncode:
    >> <input type="hidden" name="fName" value="some data that
    >> &quot;contains some quotes&quot;">
    >>
    >> There is no problem deciding where this string ends, right?
    >>
    >> Bob Barrows
    >>
    >> SteveG wrote:
    >>> It Works . No truncation using the HTMLencode.
    >>> Why do I need it? I'll be researching in parallel.
    >>>
    >>> Steve G
    >>> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    >>> news:OhZYqBwYEHA.3972@TK2MSFTNGP12.phx.gbl...
    >>>> Before I attempt to reproduce this with my web server, let me ask
    >>>> if you've tried HTMLEncode when purring the data inot the hidden
    >>>> fields?
    >>>>
    >>>> <input type="hidden" name="fName" value="
    >>>> <%= Server.HTMLEncode(Request.Form("Name")) %>">
    >>>>
    --
    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.


    Bob Barrows [MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139