how to search multiple columns in single textbox

Posted by Suneel161 under Regular Expressions on 5/3/2010 | Views : 6022 | Status : [Member] | Replies : 4
hii

i have 2 textboxs in my form. one name and technology and one button.
i enter text in seconfd textbox(java,j2ee).in db.table jave is technology column and j2ee is skillset column.
when i click button it will search name and technology(technology and skillset). how to do this..




Responses

Posted by: Vuyiswamb on: 5/3/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
You have two Textboxes in your page
First one is named "Name" and the second one is named "Technology"
In the Database table you have a technology column and Skillset column ?

So you want to search the Database values from the Single textbox entry ?

it will be easy to do that , but it comes with the bad results. What you need to do is to decide on the separator for the values

List<string> MyList = new List<string>();

MyList =split(Technology.Text,", ")


but this is not the best approach, i am not sure why you don't want to separate these search parameters, they will only confuse you.




Thank you for posting at Dotnetfunda
[Administrator]

Suneel161, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bhavna81 on: 5/3/2010 [Member] Starter

Up
0
Down
hi,
split the string using split function then go for search.
thanks.

Suneel161, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishithraj on: 5/3/2010 [Member] Bronze

Up
0
Down
Vuyiswamb is correct. You need the split the values and search the string. If you are using like keyword of sql. You can split the keywords even from database as follows.


DECLARE @Str VARCHAR(20)
DECLARE @Str1 VARCHAR(20)
DECLARE @Count INT
SET @Str='java,j2ee'
SET @Str=(REPLACE(@Str,',','.'))
SET @Count=0
WHILE @Count<=len(@Str)
BEGIN
SET @Str1=parsename(@str,@Count)
SET @Count=@Count+1


Select * from skillset where technology like @Str1 or skill like @Str1

END


Above mentioned code is not the exact one. You can add wild cards as you required also you can change the query as per your requirement.



Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Suneel161, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Er.deepakdalal on: 5/3/2010 [Member] Starter

Up
0
Down
Hi Suneel161

You wanna search the name and the technology or skillset so if we assume the your first textbox is txtName in which we enter the Name and the second text box is the txtTechnology, now you wanna search in the database so you can first split the second textbox values on the basis of the comma as guided by Mr.Vuyiswamb after that you got your technology and skillset suppose in the string variable techno and skill so your Query will be:-

Select * from Table_Name where name='" + txtName.text + "' and technology='" + techno + "'

i think it is the complete combination for completing your search try it.


Suneel161, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response