Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. 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 Professional 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
  #1 (permalink)  
Old June 5th, 2006, 01:59 AM
Authorized User
 
Join Date: May 2006
Location: Bradford, , United Kingdom.
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default Apostrophe in a textarea

Hi,
How do I get round the problem of an (') apostrophe in a textarea?
Thanks.

  #2 (permalink)  
Old June 5th, 2006, 02:57 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can you be more specific, what is the problem and do you have an example?

Cheers,

Chris

  #3 (permalink)  
Old June 5th, 2006, 03:57 AM
Authorized User
 
Join Date: May 2006
Location: Bradford, , United Kingdom.
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When someone enters a word, say it's or I'm the form is not processed. I get an error message. If written without the apostrophe then the data is accepted.
From that I am ssuming, it's the apostrophe 'bug'.

  #4 (permalink)  
Old June 5th, 2006, 04:08 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sounds like you may be doing something with sql on you subsequent page, what is the error message and code on the line causing the error?

  #5 (permalink)  
Old June 5th, 2006, 04:06 PM
Authorized User
 
Join Date: May 2006
Location: Bradford, , United Kingdom.
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression ''I'm testing')'.
/TheMiddlePath/matconfirm.asp, line 41




  #6 (permalink)  
Old June 6th, 2006, 02:51 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

If you replace any single quotes in your strings with a pair of single quotes in your SQL statement, everything should work fine, e.g.
Code:
INSERT INTO myTableName(myFieldName) VALUES('I''m testing');
HTH,

Chris

  #7 (permalink)  
Old June 6th, 2006, 01:06 PM
Authorized User
 
Join Date: May 2006
Location: Bradford, , United Kingdom.
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you.
But the word I'm testing was put into the 'textarea' on the form and the error came up. Other users may put other words that contain an apostrophe.

This textarea sends info to a MEMO field in ACCESS.

how do I resolve this?
TIA

  #8 (permalink)  
Old June 6th, 2006, 01:15 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Take a look here: http://www.adopenstatic.com/faq/80040e14.asp#scenario3a

The idea is that you replace a single quote with two quotes every time you try to update the database (either with an INSERT or an UPDATE statement). The database will know that '' actually means the literal value of ' and won't cause an error. However, only a single ' will be inserted in the database, so next time you need to get the data from the database, it'll look fine.

If you follow the link to the sample function, you see how you can create and use the Replace function to replace each single quote with a pair of quotes.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
  #9 (permalink)  
Old June 8th, 2006, 07:26 AM
Authorized User
 
Join Date: May 2006
Location: Bradford, , United Kingdom.
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Still struggling...
Any chance of seeing an example with my code?

(an extract of my code)
mySQL = "INSERT into TABLE(BroDesc)"
mySQL = mySQL & " VALUES ('" & request.form("BroDesc") & "')"
myCon.execute(mySQL)

Hope to hear...



  #10 (permalink)  
Old June 8th, 2006, 07:32 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Where is your Replace code??

Try something like this:

Dim myValue
myValue = Replace(request.form("BroDesc"), "'", "''")

Then use myValue instead request.form("BroDesc") in the rest of your code.


Imar




Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you translate an apostrophe? IronStar XSLT 2 November 13th, 2006 12:35 PM
cdonts and apostrophe bostonrose Classic ASP Components 3 October 23rd, 2006 08:20 AM
Javascript validation for apostrophe crmpicco Javascript How-To 2 March 2nd, 2005 06:57 AM
Apostrophe in textarea Renu ASP.NET 1.0 and 1.1 Basics 3 September 8th, 2004 02:13 PM
display vbCrLf's from textarea to textarea mat41 Classic ASP Basics 8 June 10th, 2004 12:19 AM





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