Results 1 to 2 of 2

Thread: SQL and Apostrophes

  1. #1

    Thread Starter
    Hyperactive Member DaveR's Avatar
    Join Date
    Mar 2001
    Location
    Ireland
    Posts
    268

    Question SQL and Apostrophes

    Hello,

    How do you deal with apostrophes when you are dealinf with a SQL statement?


    i.e. , using update statement with one of the criteria containing an apostrophe - it gives an error

    i.e. update name set code = 1 where name = ' " & name1 & " '

    and name1= Smith's


    Any ideas?
    DaveR

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: SQL and Apostrophes

    Originally posted by DaveR
    Hello,

    How do you deal with apostrophes when you are dealinf with a SQL statement?


    i.e. , using update statement with one of the criteria containing an apostrophe - it gives an error

    i.e. update name set code = 1 where name = ' " & name1 & " '

    and name1= Smith's


    Any ideas?
    use the replace function
    Code:
    "update name set code = 1 where name =  '" & replace(name1,"'","''") & "'"

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