locked
wildcard and parameter in query RRS feed

  • Question

  • User-1320152836 posted

    Hi, Could anyone help on how to write a query than has wildcard and parameter both in it. I need to get all the [Store Name] that Starts any text in a text box. I use type-dataset, but when i cant find the correct grammer in the Query Build window. Eg if user entered "cam" in the textbox. the query should return cambridge, camabley etc. 

    I tried
    WHERE     (STORE_NAME LIKE %?)
    WHERE     (STORE_NAME LIKE "%?")
    WHERE     (STORE_NAME LIKE "%"?)

    None of them worked.

    Wednesday, February 27, 2008 10:05 AM

Answers

  • User-821857111 posted

    Access uses the asterisk * as a wild card.

    That will only work if you are running the query from within Access, which a web app doesn't.  All calls to the database are via OleDb, for which the wildcard is %.  Even if you create a saved query in Access and call it via OleDb, you have to use the % character.

    It's probably more helpful and accurate not to think of the mdb file as an Access database.  Actually it's a Jet database, and you don't even need Access to create one.


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 28, 2008 4:19 PM
  • User-1320152836 posted

    got it! it should be

    STORE_NAME LIKE '%' & ? & '%'

     

    Thanks you all!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 10, 2008 6:32 AM

All replies

  • User187056398 posted

    Access uses the asterisk * as a wild card.

    Wednesday, February 27, 2008 1:52 PM
  • User-821857111 posted

    Where Store_name Like '%' + ? + '%'

    The above will return any word with CAM anywhere in it.

     

    Thursday, February 28, 2008 4:14 PM
  • User-821857111 posted

    Access uses the asterisk * as a wild card.

    That will only work if you are running the query from within Access, which a web app doesn't.  All calls to the database are via OleDb, for which the wildcard is %.  Even if you create a saved query in Access and call it via OleDb, you have to use the % character.

    It's probably more helpful and accurate not to think of the mdb file as an Access database.  Actually it's a Jet database, and you don't even need Access to create one.


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 28, 2008 4:19 PM
  • User187056398 posted

    Hey, thanks for the info.

    Thursday, February 28, 2008 6:01 PM
  • User-1320152836 posted

    got it! it should be

    STORE_NAME LIKE '%' & ? & '%'

     

    Thanks you all!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 10, 2008 6:32 AM