Microsoft Knowledge Base Email Alertz

(243724) - A basic search results page utilizing an SQL-style query for Site Server Search can be constructed in relatively few lines of code. The code presented in this article is a commented example of such a page.

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 243724 - Last Review: February 3, 2000 - Revision: 1.0

An Example Search Results Page Utilizing a SQL-Style Query for Site Server Search

This article was previously published under Q243724

SUMMARY

A basic search results page utilizing an SQL-style query for Site Server Search can be constructed in relatively few lines of code. The code presented in this article is a commented example of such a page.

MORE INFORMATION

<%@ Language="VBScript" %>
<HTML>
<BODY>
<%
' Create and set up the connection to Search.
Set objConn = Server.CreateObject ("ADODB.Connection")
objConn.ConnectionString =  "provider=mssearchsql;" 
objConn.Open

' Create and set up the Command object.
Set objCmd = Server.CreateObject("ADODB.Command")
Set objCmd.ActiveConnection = objConn

' Build the SQL Statement. 
strSQLText = "SELECT Title, DocAddress, Description, Rank" & _
	" FROM <Catalog Name>..Scope()" & _
	" WHERE Contains('<Query Text>')" & _
	" ORDER BY Rank DESC, Title"

' Set and execute the query entered by the user.
objCmd.CommandText = strSQLText
Set objRS = Server.CreateObject ("ADODB.Recordset")
objRS.Open objCmd

' 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
objConn.Close
Set objConn = Nothing
%>
</BODY>
</HTML>
				

APPLIES TO
  • MSN Search, when used with:
    • Microsoft Site Server 3.0 Standard Edition
Keywords: 
kbhowto KB243724
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate