Results 1 to 8 of 8

Thread: error in search query [RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Manila, Philippines
    Posts
    486

    error in search query [RESOLVED]

    i have data in different tables, then i want to query them by calling their product name, everything seem going well until i have a data with an apostrophe in it's name.
    Last edited by kulitag; Apr 4th, 2005 at 01:27 AM. Reason: RESOLVED

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: error in search query

    Can you substitute two apostrophes instead?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Manila, Philippines
    Posts
    486

    Re: error in search query

    no can do sir coz the system is for the use of other user. the just encode the products. it's for my inventory system.

  4. #4
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: error in search query

    I think what dglienna means is that you do something like this:
    VB Code:
    1. Dim sql As String
    2. Dim PName As String
    3. PName = "Woka'[color=black]s Widget"[/color]
    4.  
    5. sql = "Select [blah] From [Inventory] "
    6. sql = sql & "Where [Product Name] = '" & Replace$(PName, "'", "''") & "'"
    The Replace$() function is searching the product name for a single apostrophe " ' ", and replacing it with two apostrophes, " ' ' " (I've expanded these to make it easier to see what's going on). Your query should then work OK with names containing apostrophes.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Manila, Philippines
    Posts
    486

    Re: error in search query

    will it work if i search a record with no apostrophe?

  6. #6
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: error in search query

    Yes. No problem.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: error in search query

    Thanks. I was suggesting the same thing. You explained it well.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Manila, Philippines
    Posts
    486

    Re: error in search query[resolved]

    ei guys thanx for the time. i really appreciate it. GOD BLESS

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