Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Angry Apostrophe problem

    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???

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    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:
    Code:
    yourVariable = Replace(yourVariable, "'", "''")

  • #3
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbs up

    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

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Also see the sticky at the top of this forum: http://www.codingforums.com/showthread.php?t=9843
    OracleGuy

  • #5
    New Coder
    Join Date
    Aug 2003
    Location
    Shawnee Mission, Kansas
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    John Shepard
    Beyond The Impossible
    -----------------------------
    http://freeasphelp.tech.nu/
    FreeASPHelp by John Shepard
    Sign Up for a free account today!
    100% Free ASPHelp

  • #6
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Smile

    Thanks.... you guys are super helpful .... And considering the fact that I'm just starting to learn this ASP stuff u guys have pushed me up a notch.

    My Question:
    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?

  • #7
    Regular Coder
    Join Date
    Oct 2004
    Location
    In front of this computer. (Where else?)
    Posts
    442
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Reserved keywords:
    http://msdn.microsoft.com/library/de...ra-rz_9oj7.asp
    Make sure you don't use any of those as your tablenames. That gave me quite a headache for some time.
    Tomorrow is the first day of the rest of your life... What have you done today?
    Tutorials
    Web: w3schools, htmldog General tips: Hardware, Networking


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •