Wrox Programmer Forums
|
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP 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 December 1st, 2003, 11:16 AM
Authorized User
 
Join Date: Jul 2003
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default Text Entry to Access DB

I am trying to create a textarea that can be inserted into an Access 2000 DB memo field. I am hoping to set the textarea up with no restrictions on the entries, but am having trouble dealing with single and double quotes ( ' " ).

The following is the information typed into the text area between the []'s:

[

"Double"

'Single'

]

I need to pick up the quotes and the CrLf characters...haven't gotten to the crlf yet, but am having trouble formatting the INSERT command.

I can get the double quotes into the DB with the following format(JavaScript):

DevotionalTextNew = "\"Double\" "

SQL = "INSERT INTO DevotionalData "
+ "(EffDate, Devotion) "
+ "VALUES ('" + EffDate + "', '" + DevotionalTextNew + "')";

but when I try to add the single quotes, I'm not able to get the syntax setup correctly.


DevotionalTextNew = "\"Double\" and \'Single\' "

SQL = "INSERT INTO DevotionalData "
+ "(EffDate, Devotion) "
+ "VALUES ('" + EffDate + "', '" + DevotionalTextNew + "')";

gives error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''"Double" and 'Single' ''.

/Devotional/PostDevotionalToDBSQL.asp, line 93

How do I format a text string with single quotes for insertion into the DB?

Thanks for the help.




__________________
Ego is a faithful friend; He stays with us all the way to the crater.
 
Old December 21st, 2003, 07:42 PM
Registered User
 
Join Date: Dec 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hoffman,

This is a problem i have suffered with myself. Here is how I handled it.

There are 2 ways to do it

Solution 1. Double charsactors
use "" and '' the problem with this is that the "" is useful only in the VB elements of the script and the '' is only useful in the SQL query parts of the script.
Not very nice but it does work.

Solution 2. prefer option.
Do it the way HTML handles it convert the charactors to something else and convert them back when you want to use them.
use the Replace command

newtxt = Replace(txt,"'","''") 'This works for Jet (Access) SQL
newtxt = Replace(newtxt,"<","&lt;")
newtxt = Replace(newtxt,">","&gt;")
newtxt = Replace(newtxt,"""","&quot;")
newtxt = Replace(newtxt,vbCrlf,"<br>&nbsp;")
newtxt = Replace(newtxt,"\n","<br>&nbsp;")





Similar Threads
Thread Thread Starter Forum Replies Last Post
is this user on/offline? boolean db entry? ALEX_GRIM Classic ASP Basics 6 February 5th, 2005 06:30 AM
Converting Access DB to Online DB eyal8r Access 5 December 6th, 2004 05:22 AM
access db to sql server db mikersantiago Classic ASP Basics 4 November 16th, 2004 03:33 AM
Checking for a entry in access aadz5 ASP.NET 1.0 and 1.1 Basics 4 November 17th, 2003 10:49 PM





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