Results 1 to 4 of 4

Thread: Database

  1. #1
    Guest

    Post

    I have a sql statement where i pass a variable instead of passing the value directly. for ex:

    strQuery = ("Select * from tablename" _
    & " where [Company Name]= " & "'" + Trim(variablename) + "'")

    when I pass ABC as variable value its working fine. But when I pass ABC's as the value it is giving me a error.

    any help might help.

    thankyou.

  2. #2
    Lively Member
    Join Date
    Jan 1999
    Posts
    82

    Post

    Hi,

    Try replacing the single quote with two single quotes side by side:

    Abc's --> Abc''s

    HTH,

    Preeti


  3. #3
    Guest

    Post

    I tryed doing that it doesnt do any good.

  4. #4
    Lively Member
    Join Date
    Jan 1999
    Posts
    82

    Post

    Hi,

    Okay, this might get confusing:

    You have to surround the whole string in double quotes and then place physically place a single quote. And the quotes need to be treated as strings and not string delimiters:

    "VALUES(""ABC" & "'" & "S"")"

    The first two double quotes places one double quote before the ABS as a string, then the & "'" & adds the single quote as a string, then the "S"", places a double quote after the S still as part of the string.

    HTH,

    Preeti

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