SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 14th, 2004, 06:43 PM
edp1959 edp1959 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 36 edp1959 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Arrow Help with SQL LIKE

I have a search form that has a text box called "searchTxt" where I want the user to be able to type in any part of the name he is searching for. When the search button is clicked, it should show all the items from my database that contain that text in the table.

If I put the text I'm searching for in the SQL it works fine.
SQlStr="SELECT item_number, description, description2 FROM tblPartsMaster WHERE item_number LIKE '%SB%'"

How do I look at what is in the text box on my form and search for that?

Reply With Quote
  #2  
Old February 14th, 2004, 07:22 PM
MJoTaM MJoTaM is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: UK
Posts: 131 MJoTaM User rank is Private First Class (20 - 50 Reputation Level)MJoTaM User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 12 h 33 m 37 sec
Reputation Power: 5
Wink

Hi there i think you just need to parse as a variable something like:

Code:
'Var to hold the information the user insert it in the text box
Dim strTextbox

'Grab the info from the text box and hold in the var we just create
If Request.Form <> "" Then
strTextbox = Request.Form("NAMEOFTHETEXTBOX")
End If


As for the SQL Statment in your case something like this
Code:
SQlStr="SELECT item_number, description, description2 FROM tblPartsMaster WHERE item_number LIKE '" & strTextbox & "'"

or
Code:
SQlStr="SELECT item_number, description, description2 FROM tblPartsMaster WHERE item_number LIKE '%" & strTextbox & "%'"



Hope it helps

Reply With Quote
  #3  
Old February 14th, 2004, 08:57 PM
edp1959 edp1959 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 36 edp1959 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Your second suggestion worked fine. Thanks for the help.

Reply With Quote
  #4  
Old February 15th, 2004, 04:42 AM
MJoTaM MJoTaM is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: UK
Posts: 131 MJoTaM User rank is Private First Class (20 - 50 Reputation Level)MJoTaM User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 12 h 33 m 37 sec
Reputation Power: 5
Cool, no problem.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Help with SQL LIKE


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT