Solved

single quote ASCII

Posted on 2004-04-22
3
1,051 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
  • 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 100 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now