Results 1 to 8 of 8

Thread: [RESOLVED] problem inserting/updating

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    255

    Resolved [RESOLVED] problem inserting/updating

    Hello,

    I get a syntax error when insurting,updating my database if a user uses an apostrophie.
    ie: there's
    i seem to remember at college they told us there was somthing you could put after the string to remove the apostrophies but i cant for the life of me remember what it was!

    does anyone out there know how to remedy my problem???

    any help woulod be great!

    thanks,

    Iain

  2. #2
    Addicted Member
    Join Date
    Oct 2006
    Location
    Chennai, India
    Posts
    198

    Re: problem inserting/updating

    Can you tell the DB that you are using???. If its MSAccess / SQL Server you need to use the square brackets like.... [world's].
    Last edited by cheenu_vasan; Jan 31st, 2008 at 08:21 AM.
    Regards
    Srinivasan Baskaran
    India

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    255

    Re: problem inserting/updating

    how i'm doing it is the user fills in a richtext box in my .net program the data they have entered is given to a string vairable and this vairable is entered into the database via an sql command.

    if i put a square round my vairable it will insert the whole string and not mess of because of the apostrophes?

  4. #4
    Addicted Member
    Join Date
    Oct 2006
    Location
    Chennai, India
    Posts
    198

    Re: problem inserting/updating

    Try using the Double single quote for having single quote in your data.

    Try searching your text for single singlequote and replace it with double singlequote
    Regards
    Srinivasan Baskaran
    India

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: problem inserting/updating

    We could probably write a book just on how many times this particular question has been asked.

    If you do a search on this subject, you will get a ton of returns and answers. In addition, I believe this is covered in our Database FAQs.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    255

    Re: problem inserting/updating

    i'm not sure how i go about searing my string and replacing the apostrophe with a double single quote.
    could you please post an example

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: problem inserting/updating

    Actually it's better if you don't do that.. it only solves one of the potential problems, and it is very hard to tell what the others may be (it varies by database system and various other factors).

    The safest way to go is to use a Command object and put the values in via Parameters, which will also solve all of those other issues for you (without you even knowing what they are!). jmcilhinney posted an example in another one of your threads, here

    As a bonus, you don't need to worry about delimiters or formatting dates etc, as it will automatically fill them in for you, as appropriate for the database system you are connected to!

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    255

    Re: problem inserting/updating

    Thank you all very much for your help!
    Got it sorted now

Posting Permissions

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



Click Here to Expand Forum to Full Width