Solved

Replace characters from string

Posted on 2009-06-30
5
629 Views
Last Modified: 2012-05-07
Hi,
I'm rying to replace some special characters from a string before submittng to a DB, in particualr the ", I know I can use the replace command but cannot get this working for " with '

      MyComments = Request.Form("comments")
      MyComments = Replace(MyComments ,"""","'")
0
Comment
Question by:sanjshah12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 24744962
Try this:
chr(34) = "
chr(39) = '
MyComments = Request.Form("comments")
MyComments = Replace(MyComments ,chr(34),chr(39))
0
 

Author Comment

by:sanjshah12
ID: 24745020
Thanks for the reply, I get an error with the script

Microsoft VBScript compilation error '800a0409'
Unterminated string constant
/AddComments.asp, line 39
chr(34) = "
-----------^

0
 
LVL 67

Accepted Solution

by:
sirbounty earned 125 total points
ID: 24745036
Sorry those were comments...just the last two lines:
MyComments = Request.Form("comments")
MyComments = Replace(MyComments ,chr(34),chr(39))

Open in new window

0
 

Author Comment

by:sanjshah12
ID: 24745099
Cool thanks - apologies about the comment - it was me being daft! thanks again!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 24745106
No worries - glad I could help.  Thanx for the grade! :^)
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question