CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2001
    Posts
    9

    search for simliar text

    My VB application provides a search facility for user to search for a particular restaurant.
    the application allow the user to enter the restaurant name and search against the database (MS access) and return with record that have similar name.
    i use the SQL:
    Search_Data1.DatabaseName = App.Path & "\eat&go out guide.mdb"
    Dim qry

    qry=" SELECT Restaurants.RestName FROM Restaurants"
    qry = qry + " WHERE Restaurants.RestName LIKE" + "'" + "%" text1.text + "%" + "'"

    Search_Data1.RecordSource = Qry
    so if the user enter "royal" in the text box, it should return all records with name that had "royal" ..but it doesn't work..
    can anyone tell me what is wrong with the query....thanks





  2. #2
    Join Date
    Mar 2000
    Location
    Pensacola, FL
    Posts
    2

    Re: search for simliar text

    Access does not use the % character as a wildcard, instead it uses the * character. Try this queury instead.

    qry=" SELECT Restaurants.RestName FROM Restaurants"
    qry = qry + " WHERE Restaurants.RestName LIKE" + "'" + "*" text1.text + "*" + "'"

    Search_Data1.RecordSource = Qry




    I hope this helps you.

    Sean Wilkening
    IVR/CTI Programmer Analyst


  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: search for simliar text

    qry=" SELECT Restaurants.RestName FROM Restaurants"
    qry = qry + " WHERE Restaurants.RestName LIKE '%" & text1.text & "%'"


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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

Featured