Question : ASP.NET Search script

Website Search functionality / ASP.NET / SQL
I was looking for some search features similar to what is on LandWatch.com. I have seen different variations of this, but in a nutshell, it breaks down exsiting categories and sub-categories and lists the number of items in each, which is retrieved from a database.

Does anyone know of any script in ASP.NET 2.0 that would be a good starting point for this?

Thanks in advance for your time...

Answer : ASP.NET Search script

Well i cant really give a sample but i can tell you what you need to do

The best way to attack this is by using the DataSet class and a set of sql statements

each statement will collect the data for a particular category and by stacking the statements and sending them as one query you can catch each result set as a datatable within the dataset

 a typical example of a statement would be something like

SELECT *,(SELECT count(*) FROM tblItems WHERE ItemCategoryID = CategoryID) as NumItems FROM tblCategories WHERE "All my conditions are met";
SELECT DISTINCT(ItemColumn), (SELECT COUNT(*) FROM tblItems AS TBL WHERE TBL.ItemColumn= tblItems.ItemColumn) as NumItems FROM tblItems;

When looping throug the datatable you could output in the following way

dim txt as string = ""
   
for each dr as datarow in ds.tables(0).rows
    txt &= "<a href=""some.aspx?catid=" & dr("CategoryID") & """>" & dr("CatName") & " (" & dr("NumItems") & ")</a>"
next

'Add a section seperator
txt &= "<hr/>"

for each dr as datarow in ds.tables(1).rows
    txt &= "<a href=""some.aspx?distinction=" & dr("ItemColumn") & """>" & dr("ItemColumn") & " (" & dr("NumItems") & ")</a>"
next
 

Random Solutions  
 
programming4us programming4us