How to implement LIKE Clause in Table Adapters?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saadkhan
    New Member
    • Aug 2008
    • 40

    How to implement LIKE Clause in Table Adapters?

    I want to find a certain string pattern from database and u`v used the following query for that:
    SELECT * FROM myTable
    WHERE name LIKE 'a%'

    But i want to search a pattern which is been given by the user a the same time. Can there be a variable there with LIKE?
  • JamieHowarth0
    Recognized Expert Contributor
    • May 2007
    • 537

    #2
    Try putting this into a stored procedure to make it type-safe:

    Code:
    CREATE PROCEDURE findInfo
    @param nvarchar(MAX)
    AS
    BEGIN
    SELECT * FROM table WHERE ProviderID LIKE @param + '%'
    END
    GO
    Then, in your ASP code, set your SQL string to this:
    Code:
    strSQL = "EXEC findInfo 'a'"
    Hope this helps.

    codegecko

    Comment

    Working...