Results 1 to 6 of 6

Thread: SQL Select string where search criteria contains a ' character? [RESOLVED FISH]

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    SQL Select string where search criteria contains a ' character? [RESOLVED FISH]

    I have a surname in my DB, which is:

    O'Keafe

    But if I build a search SQL string like:
    Code:
    SELECT * FROM tblUsers Where Surname = 'O'Keafe'
    then this gives an error

    Any ideas?

    Woka

  2. #2

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    How could you not know something as simple as this? And you got a new job??!?

    Somebody save us!

  4. #4

  5. #5
    Addicted Member
    Join Date
    Sep 2011
    Posts
    163

    Re: SQL Select string where search criteria contains a ' character? [RESOLVED FISH]

    i have the same case ..

    but im about to search in a database

    i created a table named tblBook, with fields BookId BookName and Copyright,i have a record on BookName which is One's Self

    "Select BookId From tblBook where BookName like '" & txtBookName.Text & "' "
    i have this code in visual basic 6.0..

    errors occur about the apostrophe sign (')

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

    Re: SQL Select string where search criteria contains a ' character? [RESOLVED FISH]

    Welcome to VBForums

    Please do not reply to old threads just because they have a similar issue. For a variety of reasons it is better to create a new thread instead, and if apt link to the old one.

    For information on how to solve the issue, see the article How do I put the ' character into an SQL string? from our Database Development FAQs/Tutorials (at the top of the Database Development forum)

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