Solved

single quote ASCII

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

911 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

22 Experts available now in Live!

Get 1:1 Help Now