View Full Version : Apostrophe problem
12-26-2004, 06:26 PM
Hey I created a guestbook on my site right... i'm using ASP and a MS Access database... the user message field is of "memo" field type....
It works perfectly.... but the minute you try using say an apostrophe in the guestbook i get the following error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''I'm just signing your guestbook')'.
Is there a way i get around that problem???
12-26-2004, 06:40 PM
When you have an apostrophe the database thinks it's the end of the statement, you need to replace the string to it can be entered into a field correctly, you use the Replace function to do this:
yourVariable = Replace(yourVariable, "'", "''")
12-26-2004, 08:38 PM
So thats like a funciton that traverses the entire variable and replaces the first instance of whats inside the quotes with what comes in the second quotes?
I'll try that... thnx
12-26-2004, 08:39 PM
Also see the sticky at the top of this forum: http://www.codingforums.com/showthread.php?t=9843
12-26-2004, 09:04 PM
Read Brandoe85 comments, all you need to do is double up '
when saved in database it will have only one ', but it will save without problems
12-27-2004, 05:18 AM
Thanks.... you guys are super helpful :) :) :thumbsup: .... And considering the fact that I'm just starting to learn this ASP stuff u guys have pushed me up a notch.
My Question: :confused:
I was wondering tho... To add to the efficiency of my guestbook code, are there any other characters that I need to worry about or take into consideration to prevent unexpectable errors from happening when users use the guestbook. I mean, the apostrophe problem is the only problem I've come across but surely its not the only one I need to make provisions for? :cool:
12-27-2004, 10:22 AM
Make sure you don't use any of those as your tablenames. That gave me quite a headache for some time.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.