Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 3rd, 2004, 06:23 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with " ' " (single quotes)

Hello Everybody!

I`ve got a simple question to you guyz! Is there any way to allow single quotes ( ' ) to be inserted in a SQL string in order to insert a record in my db?

For example if I try to insert the value "john's" an error will occur because the single quote will end the query in my SQL string.

Is there a solution for that prob.? or should I forbid the users entering single quotes with VB script?
 
Old September 3rd, 2004, 07:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Double up the single quotes, so use
Code:
Replace(yourvariable, "'", "''")
before doing the insert/update
 
Old September 3rd, 2004, 08:50 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Default

pgtips thank you for your quick reply and for your helpful tip!

It works great! Thank you!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Please explain single and double quotes rsgracey BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 4 June 8th, 2006 07:20 PM
displaying single quotes and double quotes ren_123 Classic ASP Databases 2 February 22nd, 2006 02:17 PM
Single Quotes in MySQL fields Dave Brown Beginning PHP 1 June 10th, 2005 06:49 AM
Problem with single quotes ' mnoon Access 7 March 16th, 2005 03:44 PM
Double Quotes and Single Quotes Problem phungleon Classic ASP Basics 7 May 27th, 2004 01:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.