1.11M Members

Retrieve multiple options from SQL Database Column from TextBox

 
0
 

What I am trying to do is have a user enter a word into a text box and retrieve the information from a SQL database where the 'entered word' eqauls that a column. I have this working perfectly but now I would like the user to be able to enter multiple words to search for. The trouble I'm having is that it's looking for all of the words in a single entry.

Here is my vb.net code to pass the textbox entry to the stored procedure:

Session("Suburb") = TbSuburbs.Text
Dim parameterSuburb As SqlParameter = New SqlParameter("@suburb", SqlDbType.VarChar, 50)
parameterSuburb.Value = Session("Suburb")
myCommand.SelectCommand.Parameters.Add(parameterSuburb)

And the stored procedure

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[Search_Realestate] 
(
	
	@RegID as varchar(50),
	@category as varchar(50),
	@price_min as int,
	@price_max as int,
	@bed as varchar(50),
	@car as varchar(50),
	@bath as varchar(50),
	@suburb as varchar(100)
) 

as

select 
	headline as headline,
	subNumber as subNumber,
	streetNumber as streetNumber,
	street as street,
	suburb as suburb,
	'$' + convert (varchar (50),price,105) as price,
	bedrooms as bedrooms,
	bathrooms as bathrooms,
	garages as garages,
	description as description,
	image1 as URL1, 
	category as category,
	
	Ref_No as RefNo,
	Rowguid
	from Realestate
	Where @RegID = 'Admin' and category = @category and price >= @price_min and price <= @price_max
	and bedrooms >= @bed and bathrooms >= @bath and garages >= @car
	and suburb LIKE @suburb

So any help with this would be great. I would like to eventually like to give the textbox an auto complete element to it, so if you know any good tutorials for that I would appreciate it.

 
0
 

Sorry just realised I posted old code the last line is:

and suburb IN (@suburb)
 
0
 

use Like in sql for multiple keyword data find

 
0
 

I've tried LIKE with the same results. Works with one keyword but not multiple

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: