• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1093
  • Last Modified:

single quote ASCII

I am trying to pass to an update SQL statement a textfield value which might contain a single quote and this generate an error.
How can I convert a single quote into an ASCII character in a string "adfd  '  fd". Basically I would like to go through every character in a string and convert single quote character into a special character that will be accepted by SQL.
  • 2
1 Solution
TransBindAuthor Commented:
seems like it works out if I replace single quote with two singles quotes. is this a good approach? any suggestions are welcomed. thank u.
try here..


Function ReplaceQuotes(value)
value = Replace(value, "'", "''") 'Replace single quotes
value = Replace(value, """, """") 'Replace double quotes
ReplaceQuotes = value
End Function

best of luck

try this..also..

strSQL="insert into table_name values"strSQL=strSQL & "(NAME='"strSQL=strSQL & replace(request("NAME"),"'","''") & "'," & request("DoB") & ")"In the above example if the value of the name field contains a single quote it will be replaced with two single quotes.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now