replacing apostrophes

Discussion in 'ASP General' started by middletree, Dec 22, 2003.

  1. middletree

    middletree Guest

    I put in some code to keep apostrophes from being a problem. However, on the
    display page, they have double quotes. What am I doing wrong?

    Here is the code on the page which captures the data from the form, right
    before it gets entered into the database:

    ------------------------------------------
    strInternalDesc =
    Replace(Replace(Trim(Request.Form("InternalDesc")),"'","''"),vbCrLf,"<br>")
    ------------------------------------------
    then, on the page where it gets displayed, I get:

    O''Rourke
     
    middletree, Dec 22, 2003
    #1
    1. Advertising

  2. middletree

    Ray at Guest

    You should use functions for passing data into a database and pulling it
    out. Maybe something along the lines of:

    You don't want to actually store "<br>" in your database. Also, in the
    SafeOut, you may also want to replace " with &quot;.

    ''For going in:
    strInternalDesc = SafeIn(Request.Form("InternalDesc"))
    ''code to instert into database

    For coming out:
    Response.Write
    SafeOut(Recordset.Fields.Item("ColumnThatContainsThatValue").Value



    Function SafeIn(theString)
    SafeIn = Replace(theString, "'", "''")
    End Function

    Function SafeOut(theString)
    SafeOut = Replace(theString, vbCrLf, "<br>")
    End Function

    Ray at work



    "middletree" <> wrote in message
    news:%...
    > I put in some code to keep apostrophes from being a problem. However, on

    the
    > display page, they have double quotes. What am I doing wrong?
    >
    > Here is the code on the page which captures the data from the form, right
    > before it gets entered into the database:
    >
    > ------------------------------------------
    > strInternalDesc =
    >

    Replace(Replace(Trim(Request.Form("InternalDesc")),"'","''"),vbCrLf,"<br>")
    > ------------------------------------------
    > then, on the page where it gets displayed, I get:
    >
    > O''Rourke
    >
    >
    >
    >
     
    Ray at, Dec 22, 2003
    #2
    1. Advertising

  3. middletree

    middletree Guest

    Ok, I can try this. I dont' really understand the difference, though.

    Also, can I add the Trim function to the SafeIn function?


    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:...
    > You should use functions for passing data into a database and pulling it
    > out. Maybe something along the lines of:
    >
    > You don't want to actually store "<br>" in your database. Also, in the
    > SafeOut, you may also want to replace " with &quot;.
    >
    > ''For going in:
    > strInternalDesc = SafeIn(Request.Form("InternalDesc"))
    > ''code to instert into database
    >
    > For coming out:
    > Response.Write
    > SafeOut(Recordset.Fields.Item("ColumnThatContainsThatValue").Value
    >
    >
    >
    > Function SafeIn(theString)
    > SafeIn = Replace(theString, "'", "''")
    > End Function
    >
    > Function SafeOut(theString)
    > SafeOut = Replace(theString, vbCrLf, "<br>")
    > End Function
    >
    > Ray at work
    >
    >
    >
    > "middletree" <> wrote in message
    > news:%...
    > > I put in some code to keep apostrophes from being a problem. However, on

    > the
    > > display page, they have double quotes. What am I doing wrong?
    > >
    > > Here is the code on the page which captures the data from the form,

    right
    > > before it gets entered into the database:
    > >
    > > ------------------------------------------
    > > strInternalDesc =
    > >

    >

    Replace(Replace(Trim(Request.Form("InternalDesc")),"'","''"),vbCrLf,"<br>")
    > > ------------------------------------------
    > > then, on the page where it gets displayed, I get:
    > >
    > > O''Rourke
    > >
    > >
    > >
    > >

    >
    >
     
    middletree, Dec 22, 2003
    #3
  4. middletree

    Ray at Guest

    "middletree" <> wrote in message
    news:...
    > Ok, I can try this. I dont' really understand the difference, though.



    Well, were you doing that replacing when you were inserting the value into
    the database or pulling it out? Normally, you'd replace ' when inserting
    and replace vbCrLfs when pulling out. You're doing both, which is out of
    the ordinary.



    >
    > Also, can I add the Trim function to the SafeIn function?


    Sure.

    Ray at work

    >
    >
    > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > news:...
    > > You should use functions for passing data into a database and pulling

    it
    > > out. Maybe something along the lines of:
    > >
    > > You don't want to actually store "<br>" in your database. Also, in the
    > > SafeOut, you may also want to replace " with &quot;.
    > >
    > > ''For going in:
    > > strInternalDesc = SafeIn(Request.Form("InternalDesc"))
    > > ''code to instert into database
    > >
    > > For coming out:
    > > Response.Write
    > > SafeOut(Recordset.Fields.Item("ColumnThatContainsThatValue").Value
    > >
    > >
    > >
    > > Function SafeIn(theString)
    > > SafeIn = Replace(theString, "'", "''")
    > > End Function
    > >
    > > Function SafeOut(theString)
    > > SafeOut = Replace(theString, vbCrLf, "<br>")
    > > End Function
    > >
    > > Ray at work
    > >
    > >
    > >
    > > "middletree" <> wrote in message
    > > news:%...
    > > > I put in some code to keep apostrophes from being a problem. However,

    on
    > > the
    > > > display page, they have double quotes. What am I doing wrong?
    > > >
    > > > Here is the code on the page which captures the data from the form,

    > right
    > > > before it gets entered into the database:
    > > >
    > > > ------------------------------------------
    > > > strInternalDesc =
    > > >

    > >

    >

    Replace(Replace(Trim(Request.Form("InternalDesc")),"'","''"),vbCrLf,"<br>")
    > > > ------------------------------------------
    > > > then, on the page where it gets displayed, I get:
    > > >
    > > > O''Rourke
    > > >
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Ray at, Dec 22, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Huddle

    SQL and apostrophes

    Chris Huddle, Dec 10, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    746
    Steve C. Orr [MVP, MCSD]
    Dec 10, 2003
  2. Andy Fish

    HtmlEncode with apostrophes

    Andy Fish, Apr 6, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    8,660
    Nicole Calinoiu
    Apr 6, 2005
  3. MS
    Replies:
    3
    Views:
    16,161
    Marcin Grunwald
    Feb 22, 2005
  4. shank

    replacing apostrophes in text box

    shank, Apr 27, 2004, in forum: ASP General
    Replies:
    8
    Views:
    208
    Steven Burn
    Apr 27, 2004
  5. Rob Meade

    Replacing - and not Replacing...

    Rob Meade, Apr 5, 2005, in forum: ASP General
    Replies:
    5
    Views:
    281
    Chris Hohmann
    Apr 11, 2005
Loading...

Share This Page