Solved

apostrophe in an SQL update

Posted on 2003-11-14
3
588 Views
Last Modified: 2008-02-01
Having problem to update a comment field when user puts an apostrophe
0
Comment
Question by:badrul_hossain
3 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 9747797
Hi badrul_hossain,

Double the apostrophe:

"Update MyTable Set MyField = '" & Replace(MyValue,"'","''") & "' Where MyOtherField = Something"

In principle, SQL server will see the two '' characters and only store one of them.

Tim Cottee MCSD, MCDBA, CPIM
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
LVL 7

Expert Comment

by:vnvk
ID: 12154811
This Question is now classified abandoned as no comment has been added to this question in more than 21 days.

I will leave the following recommendation on this question to the moderators in the Cleanup topic area:
    Accept: TimCottee {http:#9747797}

Any objections should be posted here in the next 4 days. After that time, the question will be closed at the discretion of the moderator.

vnvk
EE Cleanup Volunteer
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Get hold of longitude and latitude in iframe string 11 51
Recordset containing single quotes 8 48
One field not displaying content (ASP Classic) 8 35
ASP and Extracting XML 7 24
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

713 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