Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

single quote ASCII

Posted on 2004-04-22
3
Medium Priority
?
1,078 Views
Last Modified: 2008-01-16
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.
0
Comment
Question by:TransBind
[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
  • 2
3 Comments
 
LVL 7

Author Comment

by:TransBind
ID: 10895668
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.
0
 
LVL 23

Accepted Solution

by:
rama_krishna580 earned 400 total points
ID: 10895855
try here..

http://www.codeproject.com/books/0735616485.asp

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

best of luck

R.K
0
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 10895859
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.

R.K
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

618 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