help with search code
-
Hi friends. I am cearting my website using Asp.net ( code C# ) and sqlserver2000... I need "search" in a webform. for example, when the user types " demo " in the textbox of the search page, then it should appear all the things in all pages of the website,which is correlate with the word "demo". Just like the search in codeproject. how can I do it ? I just know about searching with a specific field,like user name,age,... but I dont have any idea about a word searching ... is there any articles which can help me? Or can anyone help me to write ...? thanks alot.
-
Hi friends. I am cearting my website using Asp.net ( code C# ) and sqlserver2000... I need "search" in a webform. for example, when the user types " demo " in the textbox of the search page, then it should appear all the things in all pages of the website,which is correlate with the word "demo". Just like the search in codeproject. how can I do it ? I just know about searching with a specific field,like user name,age,... but I dont have any idea about a word searching ... is there any articles which can help me? Or can anyone help me to write ...? thanks alot.
You want to use a 'like' query on your database which allows you to search through string which 'looks like' your string... the syntax is easy select field1, field2 from table where field1 like '%demo%' this returns all rows where field1 contains the string 'demo'. However, you may consider using and/or functionality in your websearch, for example when a visitor enters demo+csharp in the textbox. Your query should look like this select field1, field2 from table where field1 like '%demo%' and field1 like '%csharp%' If the user enters 'demo csharp' as search text, you want select field1, field2 from table where field1 like '%demo%' or field1 like '%csharp%' This makes searching complicated. Afterwards you want to sort the result set having the most relevant match on top. For example you can count the number of matches for each result in the result set and order the result set depending on that number of matches having the most matches on top. You can make search functionality as easy or as complicated as you want... ;)
I love it when a plan comes together http://www.zonderpunt.nl[^]