apostrophe replacement

M

middletree

I know this is a very commonly asked question, but I can't find a solution
anywhere that I have looked.

I need to take the text that will be typed in paragraph form by the user
(textarea field) and do two things with it:

1. Store it in a SQL Server database field
2. Send it in an email upon page submit.

Of course, single quotes have caused problems, so I have this code:
strInternalDesc =
Replace(Trim(Request.Form("InternalDesc")),"'","''")

Problem is, it shows up like this in the email that is sent:
==============================
We''re in the process of
==============================

I would like to get rid of the double apostrophes, but not sure how. Went to
an article on ASPFAQ, and saw something which directed me to do this:

strInternalDesc =
Replace(Trim(Request.Form("InternalDesc")),"'",chr(34))

However, that just makes it a regular double-quote. I guess I could try and
find out what the character number for apostrophes are, but not sure where
that is. Besides, will that mess up my SQL Server or the email if I do that?

TIA
 
A

Aaron [SQL Server MVP]

Of course, single quotes have caused problems, so I have this code:
strInternalDesc =
Replace(Trim(Request.Form("InternalDesc")),"'","''")

Problem is, it shows up like this in the email that is sent:
==============================
We''re in the process of
==============================

Well, either send the e-mail before replacing and updating the database, or
else have two variables.

strInternalDescMail = Trim(Request.Form("InternalDesc"))
strInternalDescDB = Replace(strInternalDescMail,"'","''")

A
 
M

middletree

Makes sense. Thanks!


Aaron said:
Well, either send the e-mail before replacing and updating the database, or
else have two variables.

strInternalDescMail = Trim(Request.Form("InternalDesc"))
strInternalDescDB = Replace(strInternalDescMail,"'","''")

A
 
A

Aaron [SQL Server MVP]

Makes sense. Thanks!

Hey, don't feel bad. At least you aren't one of those people stumbling on
the idea of how to send the content in an e-mail and to the database, all in
the same page. I don't understand the confusion there, do they think that
if you send an e-mail or update the database, you can't do anything else?
The page just ends? It hasn't come up recently but it has come up often
enough that I smack my head and ask, "why this again?"
 
M

middletree

Thanks. I like this. I have a question or two about a couple of things I saw
in the code, but I'll try and work those out.

thanks
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top