Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL 2000 like clause in ASP code 1

Status
Not open for further replies.

sandl4597

MIS
Jun 17, 2003
3
US
Trying to get syntax right with doing a like clause in ASP. I have the user input any amount of characters meaning they can either enter the first letter or the entire agency name that they wish to find. I need a query that takes what they enter and search the database for these characters. Please advise how I can do this within ASP to avoid errors. Thanks.
 
need to build up the sql then execute it in asp code or create a stored procedure in sql server and execute that passing it the string of characters ntered by the usere.g.

CREATE procedure ET_SP_ClientList
@client varchar(50) ='%'--default value, returns all
as
select ClientName
from
clientdata
where ClientName like ''+@client+'%

HTH

Andy
 
Using a stored proc is usually beter for performance but if you don't want to then use:

Code:
Dim strSearch
Dim strSQL

strSearch = Request.Form("myinput")

strSQL = "SELECT * FROM mytable WHERE myfield LIKE '" & strSearch & "%'"

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top