Solved

single quote ASCII

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net How to Exit Sub - Exit Form??? 5 57
Run time Error 4 47
How can my static class become undefined?? 8 47
SqlDataBase 7 46
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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 …

815 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

11 Experts available now in Live!

Get 1:1 Help Now