An Example Search Results Page for Site Server Search

ID: Q243191


The information in this article applies to:
  • Microsoft Search, included with:
    • Microsoft Site Server version 3.0


SUMMARY

A basic search results page for Site Server Search can be constructed in relatively few lines of code. This article provides code for an example of such a page.


MORE INFORMATION


<%@ Language="VBScript" %>
<HTML>
<BODY>
<%
' Create our Query object
Set objQuery = Server.CreateObject ("MSSearch.Query")

' Set the name of the catalog we are going to execute the query against
objQuery.Catalog = "<Catalog Name>"

' Set the query text we are searching for
objQuery.Query = "<Query Text>"

' Specify which columns we wish returned in our recordset
objQuery.Columns = "Title, DocAddress, Description, Rank"

' If we want the results sorted, we need to specify what our sort criteria will be.
' In our case, we will sort by descending Rank then by Title
objQuery.SortBy = "Rank[d], Title"

' Set the maximum number of records we want retrieved in our recordset
objQuery.MaxRecords = 100

' We now execute the query and get our results recordset back
Set objRS = objQuery.CreateRecordset ("sequential")

' Display the results.
Response.Write objRS.Properties ("RowCount") & " documents match the query<BR><BR>"
Response.Write "<TABLE BORDER=1>"

' Show our headers
For I = 0 To objRS.Fields.Count - 1 
	Response.Write "<TH><STRONG>" & objRS (I).Name & "</STRONG></TH>"
Next 

' We want to display information for each result in the recordset
Do While Not objRS.EOF 
    Response.Write "<TR>"

	' Display the field and associated value(s)
    For I = 0 To objRS.Fields.Count - 1 
		Response.Write "<TD>" & objRS (I) & "</TD>"
    Next
    
    Response.Write "</TR>"
    objRS.MoveNext
Loop
Response.Write "</TABLE>"


' Clean up after ourselves by closing our recordset and setting our objects equal to Nothing
objRS.Close
Set objRS = Nothing
Set objQuery = Nothing
%>
</BODY>
</HTML> 

Additional query words:

Keywords : kbDSupport
Version : winnt:3.0
Platform : winnt
Issue type : kbhowto


Last Reviewed: October 13, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.