Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I create a Search After Spacing First Word another Text matching on row

like
Button Plastic 15MM 4Hole

But I want to Search like

Plastic Hole

Thats matches two record on one column row. How to create a Search Please Help any one

I am Creating a Search Engine I required these Please help if u know or any idea please share with me

What I have tried:

I am trying to link .Contains Method
I am trying to sql wildcard.
Posted
Updated 27-Apr-16 21:13pm
Comments
Karthik_Mahalingam 28-Apr-16 0:58am    
if a row contains only plastic, do you want to return it in the results ?
Member 11151453 28-Apr-16 1:35am    
No if row contains plastic and after few words hole
Karthik_Mahalingam 28-Apr-16 1:39am    
give few examples
Member 11151453 28-Apr-16 1:43am    
Button Plastic 15MM 4 Hole
in one row data
When we want search on plastic row match then we search Plastic 15MM row match When Plastic Hole search row data not match

I want to work like this but no idea how to do code:
Select ItemName From Item Where ItemName like '%Plastic%Hole%'
Karthik_Mahalingam 28-Apr-16 1:48am    
try this
Select ItemName From Item Where ItemName like '%Plastic%' or Itemname like '%Hole%'

check this, modify the table name and column name

C#
// string text = "Button Plastic 15MM 4Hole";
           string text = "Plastic Hole";
           string[] keys = text.Trim().Split(' ');

           SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=karthik_test;Integrated Security=True");
           SqlCommand cmd = new SqlCommand();
           cmd.Connection = con;
           string query = "", likePattern = "";

           for (int i = 0; i < keys.Length; i++)
               likePattern += string.Format("%{0}", keys[i]);
           likePattern = likePattern.Trim() + "%";

           query = likePattern.Length > 0 ? "select * from  TableKeywordSearch  where  keywordcolumn like @keyword " : "select * from  TableKeywordSearch";

           cmd.CommandText = query;
           cmd.Parameters.Add("@keyword", likePattern);

           SqlDataAdapter da = new SqlDataAdapter(cmd);
           DataTable dtResults  = new DataTable ();
           try
           {
               da.Fill(dtResults);
           }
           catch (Exception)
           {

               throw;
           }
 
Share this answer
 
Comments
Member 11151453 28-Apr-16 4:56am    
Brilliant KARTHIK Get Success Thanks Karthik for help
Karthik_Mahalingam 28-Apr-16 5:05am    
welcome :)
Member 11151453 28-Apr-16 5:40am    
Can you help me running iis?
Karthik_Mahalingam 28-Apr-16 5:50am    
bro, post it as a new question. you will get lot of response from those who are aware of.
Member 11151453 29-Apr-16 8:10am    
your search code is perfectly work but search in opposite way Button Hole Plastic is not work then data is found :)

Button Plastic 15MM 4Hole


Select ItemName from Item where ItemName like '%plastic%' and ItemName like '%hole%' and ItemName like '%15mm%' or more than can be found and

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900