Using the like command in SQL

Discussion in 'ASP General' started by MasterChief, Nov 3, 2005.

  1. MasterChief

    MasterChief Guest

    I have a form that uses the POST method to call up test.asp and it
    passes what is typed into the text box. Since is uses the Like command
    the user can enter stuff like %Constant% to get something that is like
    what the user typed in. When I call up the test.asp page it is grabbing
    the text fine but isn't running the SQL command the correct way. The
    SQL command ends up being

    SELECT * FROM [Everyone] WHERE (Name LIKE ':: & strName & ::')

    Here is my code


    strName = Request.Form("Search")
    Set Conn = Server.CreateObject("ADODB.Connection")
    Set Rs = Server.CreateObject("ADODB.RecordSet")
    Conn.Open "PhoneList"
    sSQL = "SELECT * FROM [Everyone] WHERE (Name LIKE ':: & strName & ::')"
    Set Rs = Conn.Execute(sSQL)
    MasterChief, Nov 3, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HalcyonWild
    Replies:
    2
    Views:
    912
    HalcyonWild
    Dec 19, 2005
  2. Christian Seberino
    Replies:
    0
    Views:
    467
    Christian Seberino
    Oct 21, 2003
  3. Remi Morin
    Replies:
    0
    Views:
    511
    Remi Morin
    Oct 23, 2006
  4. Patrick Kowalzick
    Replies:
    5
    Views:
    458
    Patrick Kowalzick
    Mar 14, 2006
  5. MasterChief

    Using the like command in SQL

    MasterChief, Nov 3, 2005, in forum: ASP General
    Replies:
    2
    Views:
    107
    MasterChief
    Nov 4, 2005
Loading...

Share This Page