Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP 3.0 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 April 16th, 2004, 12:39 AM
Authorized User
 
Join Date: Feb 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem caused by single quote

Hi,

I have a textarea (adtext) in my form in which customer can write message. Then I insert that value in my msde database.

The problem I am having is if someone put "'" in their message my insert statments blows up, and I get error.


Suppose If the value of adtext is "Write a good 'description about yourself"

My error will be

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E14)
Line 1: Incorrect syntax near 'description'.


**************
here is my code


adtext = Request.form("adtext")

str= "INSERT INTO customer_ad(Location, Spec_Location, Adtext,ad_number, passwordhint)VALUES('" & location & "','" & speclocation & "', '" & Adtext & "'," & AdNumber & ",'" & passwordhint & "' )"
*************

I understand "'" mess up the sequences of my single quotes that I have in my insert statemnt , but i do not know how to overcome this problem

Thanks


 
Old April 16th, 2004, 02:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Code:
adtext = Replace(Request.Form("adtext"), "'", "''")
will solve your problem





Similar Threads
Thread Thread Starter Forum Replies Last Post
single quote problem harpua PHP Databases 1 July 8th, 2005 07:37 AM
How to add parameter val containing single quote prog ADO.NET 3 May 24th, 2005 09:24 AM
Undo/delete ' (single quote) in a textbox iniro VB.NET 2002/2003 Basics 1 April 6th, 2005 04:41 PM
replace single Quote qadeerahmad General .NET 3 September 6th, 2004 08:10 PM





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