Apostrophe - instert to DB and retrieve for display

Apostrophe - instert to DB and retrieve for display

am 12.01.2005 03:05:48 von SusieQ

I need to allow a comment field to be written to a small access database
through ASP and then retrieved and displayed through a ASP web page.

I can't for the life of me remember how to deal with apostrophes and special
characters.

I'm thinking commentfld=server.htmlencode("formComments")
then dbfield=commentfld

but if this is right I can't remember how to then retrieve it and display it
so it formats with the characters rather than the symbols (%20) etc.

can anyone please refresh my memory?

TIA

Re: Apostrophe - instert to DB and retrieve for display

am 12.01.2005 03:38:40 von unknown

Replace(formcomments, "'", "''")

Sample valid SQL statement:

INSERT INTO theTable (theValues) VALUES ('Eat at Joe''s Chicken Shack!')

Ray at home

"SusieQ" wrote in message
news:O37VbsE%23EHA.1544@TK2MSFTNGP11.phx.gbl...
>I need to allow a comment field to be written to a small access database
>through ASP and then retrieved and displayed through a ASP web page.
>
> I can't for the life of me remember how to deal with apostrophes and
> special characters.
>
> I'm thinking commentfld=server.htmlencode("formComments")
> then dbfield=commentfld
>
> but if this is right I can't remember how to then retrieve it and display
> it so it formats with the characters rather than the symbols (%20) etc.
>
> can anyone please refresh my memory?
>
> TIA
>
>
>
>

Re: Apostrophe - instert to DB and retrieve for display

am 12.01.2005 03:46:30 von SusieQ

Thanks for your response. However, this doesn't deal with any paragraph
markers that the user might enter into the fields, or if they should use &
in their text. I was sure it had something to do with urlencode or
htmlencode.

I'll keep looking, thanks


"Ray Costanzo [MVP]" wrote in
message news:uD1317E%23EHA.3756@TK2MSFTNGP14.phx.gbl...
> Replace(formcomments, "'", "''")
>
> Sample valid SQL statement:
>
> INSERT INTO theTable (theValues) VALUES ('Eat at Joe''s Chicken Shack!')
>
> Ray at home
>
> "SusieQ" wrote in message
> news:O37VbsE%23EHA.1544@TK2MSFTNGP11.phx.gbl...
>>I need to allow a comment field to be written to a small access database
>>through ASP and then retrieved and displayed through a ASP web page.
>>
>> I can't for the life of me remember how to deal with apostrophes and
>> special characters.
>>
>> I'm thinking commentfld=server.htmlencode("formComments")
>> then dbfield=commentfld
>>
>> but if this is right I can't remember how to then retrieve it and display
>> it so it formats with the characters rather than the symbols (%20) etc.
>>
>> can anyone please refresh my memory?
>>
>> TIA
>>
>>
>>
>>
>
>

Re: Apostrophe - instert to DB and retrieve for display

am 12.01.2005 03:58:36 von ten.xoc

If the user enters carriage returns in a textarea using the [Enter] key,
these are not the same as HTML carriage returns. Imagine if your HTML
source code treated every carriage return as a
tag? *shudder*

You escape ' by doubling them up using REPLACE, before passing the string to
the database. This is because the database needs to differentiate between
string delimiters, and embedded apostrophes that happen to look like string
delimiters.

You present carriage returns as HTML carriage by a very similar method.
Store the carriage returns as plain text, and replace them with their HTML
counterparts when presenting (not storing) the data. See
http://www.aspfaq.com/2188 for some examples.

Your other options:

(a) use

data
when presenting (not storing) the data
(b) use <%=Server.HTMLEncode(data)%> when presenting (not storing) the data

--
http://www.aspfaq.com/
(Reverse address to reply.)




"SusieQ" wrote in message
news:uF2dLDF#EHA.1296@TK2MSFTNGP10.phx.gbl...
> Thanks for your response. However, this doesn't deal with any paragraph
> markers that the user might enter into the fields, or if they should use &
> in their text. I was sure it had something to do with urlencode or
> htmlencode.
>
> I'll keep looking, thanks
>
>
> "Ray Costanzo [MVP]" wrote in
> message news:uD1317E%23EHA.3756@TK2MSFTNGP14.phx.gbl...
> > Replace(formcomments, "'", "''")
> >
> > Sample valid SQL statement:
> >
> > INSERT INTO theTable (theValues) VALUES ('Eat at Joe''s Chicken Shack!')
> >
> > Ray at home
> >
> > "SusieQ" wrote in message
> > news:O37VbsE%23EHA.1544@TK2MSFTNGP11.phx.gbl...
> >>I need to allow a comment field to be written to a small access database
> >>through ASP and then retrieved and displayed through a ASP web page.
> >>
> >> I can't for the life of me remember how to deal with apostrophes and
> >> special characters.
> >>
> >> I'm thinking commentfld=server.htmlencode("formComments")
> >> then dbfield=commentfld
> >>
> >> but if this is right I can't remember how to then retrieve it and
display
> >> it so it formats with the characters rather than the symbols (%20) etc.
> >>
> >> can anyone please refresh my memory?
> >>
> >> TIA
> >>
> >>
> >>
> >>
> >
> >
>
>

Re: Apostrophe - instert to DB and retrieve for display

am 12.01.2005 04:25:25 von SusieQ

thanks so much Aaron - I really need to make sure I look at AspFAQ before I
send to this forum. I'm moving it to the top of my help list.


"Aaron [SQL Server MVP]" wrote in message
news:er0eMMF%23EHA.2568@TK2MSFTNGP11.phx.gbl...
> If the user enters carriage returns in a textarea using the [Enter] key,
> these are not the same as HTML carriage returns. Imagine if your HTML
> source code treated every carriage return as a
tag? *shudder*
>
> You escape ' by doubling them up using REPLACE, before passing the string
> to
> the database. This is because the database needs to differentiate between
> string delimiters, and embedded apostrophes that happen to look like
> string
> delimiters.
>
> You present carriage returns as HTML carriage by a very similar method.
> Store the carriage returns as plain text, and replace them with their HTML
> counterparts when presenting (not storing) the data. See
> http://www.aspfaq.com/2188 for some examples.
>
> Your other options:
>
> (a) use

data
when presenting (not storing) the data
> (b) use <%=Server.HTMLEncode(data)%> when presenting (not storing) the
> data
>
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
>
>
> "SusieQ" wrote in message
> news:uF2dLDF#EHA.1296@TK2MSFTNGP10.phx.gbl...
>> Thanks for your response. However, this doesn't deal with any paragraph
>> markers that the user might enter into the fields, or if they should use
>> &
>> in their text. I was sure it had something to do with urlencode or
>> htmlencode.
>>
>> I'll keep looking, thanks
>>
>>
>> "Ray Costanzo [MVP]" wrote in
>> message news:uD1317E%23EHA.3756@TK2MSFTNGP14.phx.gbl...
>> > Replace(formcomments, "'", "''")
>> >
>> > Sample valid SQL statement:
>> >
>> > INSERT INTO theTable (theValues) VALUES ('Eat at Joe''s Chicken
>> > Shack!')
>> >
>> > Ray at home
>> >
>> > "SusieQ" wrote in message
>> > news:O37VbsE%23EHA.1544@TK2MSFTNGP11.phx.gbl...
>> >>I need to allow a comment field to be written to a small access
>> >>database
>> >>through ASP and then retrieved and displayed through a ASP web page.
>> >>
>> >> I can't for the life of me remember how to deal with apostrophes and
>> >> special characters.
>> >>
>> >> I'm thinking commentfld=server.htmlencode("formComments")
>> >> then dbfield=commentfld
>> >>
>> >> but if this is right I can't remember how to then retrieve it and
> display
>> >> it so it formats with the characters rather than the symbols (%20)
>> >> etc.
>> >>
>> >> can anyone please refresh my memory?
>> >>
>> >> TIA
>> >>
>> >>
>> >>
>> >>
>> >
>> >
>>
>>
>
>