Notices

Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

Thread: Using LIKE '%variable%' with a parameterized query

Results 1 to 2 of 2
Share This Thread →
  1. #1
    jplace is offline Registered User
    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    Using LIKE '%variable%' with a parameterized query

    I am trying to accomplish something like...

    SELECT ItemID, ItemNumber, ItemDesc FROM ITEMS WHERE ItemDesc LIKE '%variable%'

    The problem is I am using a parameterized query, so it is structure like...

    rsItems_cmd.CommandText = "SELECT ItemID, ItemNumber, ItemDesc FROM ITEMS WHERE ItemDesc LIKE ?"

    and then passing the parameter...

    rsItems_cmd.Parameters.Append rsItems_cmd.CreateParameter("param1", 200, 1, 50, rsItems__Variable

    (Where rsItems__Variable is a string of the value passed)

    How do I use a LIKE command when passing a text string as a parameter??

  2. #2
    bigmike1212's Avatar
    bigmike1212 is offline 0x800A0C93
    Join Date
    Jan 2009
    Location
    Ridin' through this world...
    Posts
    2,975
    Rep Power
    1310
    Try:

    'set the variable with initial value
    rsItems__Variable= source of whereever it is coming from

    'append the %'s to it before feeding it to the query
    rsItems__Variable= "%" & rsItems__Variable & "%"
    Brinkster- free development account. Not affiliated, but I sure like free. Brinkster.com

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

Similar Threads

  1. Parameterized Query - Must declare the variable
    By Nishana in forum ASP Development
    Replies: 12
    Last Post: June 4th, 2009, 02:41 AM
  2. Problem with Parameterized Query
    By Computer-bot in forum ASP Development
    Replies: 1
    Last Post: December 27th, 2007, 01:22 PM
  3. Variables of Parameterized query
    By Computer-bot in forum ASP Development
    Replies: 3
    Last Post: December 27th, 2007, 12:59 AM
  4. Parameterized Query
    By Computer-bot in forum ASP Development
    Replies: 18
    Last Post: October 21st, 2007, 07:04 AM
  5. Parameterized SQL Query
    By rmoghal in forum .NET Development
    Replies: 4
    Last Post: June 15th, 2005, 02:28 PM

ASP Free Advertisers and Affiliates