Microsoft KB Archive/288435

= HOW TO: Query Index Server Data by Using ASP in FrontPage 2000 =

Article ID: 288435

Article Last Modified on 11/14/2005

-

APPLIES TO


 * Microsoft FrontPage 2000 Standard Edition
 * Microsoft Internet Information Services 5.0

-



This article was previously published under Q288435





SUMMARY
Use this step-by-step guide to create a customized Index Server search page by using Active Server Pages (ASP) in FrontPage 2000.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. (back to top)

Step 1 - Prepare to Use the ASP Features in FrontPage
Before you can use the ASP features in FrontPage 2000, install the components listed in the following Microsoft Knowledge Base article:

312638 FP: What You Need to Use Active Server Pages (ASP) in FrontPage

(back to top)

Step 2 - Create a Form Page in FrontPage
 In FrontPage, open a Web site on a Windows 2000 Web Server. Click the New Page button on the Standard toolbar. On the Insert menu, point to Form, and then click One-Line Text Box.  Double-click the text box. Change the name to QUERYTEXT. For the initial value, type the following: <%=Request(&quot;QUERYTEXT&quot;)%> Click OK.  Click after the text box. Add a drop-down menu to the form. To do this, point to Form on the Insert menu, and then click Drop-Down Menu. Double-click the drop-down menu and change the name to QUERYFIELD.</li> Click Add. For choice, type DocAppName. Clear the Specify Value check box if necessary, and then click OK.</li> Repeat step 8 to add the following menu choices:

Characterization

FileName

DocAuthor

DocTitle

</li> Click OK to close the Properties dialog box.</li> Right-click the Submit button and then click Form Properties on the menu that appears.</li> Click the Send to other option, and then click Options.</li>  In the Action box, type the following: <%=Request.ServerVariables(&quot;URL&quot;)%> Click OK. </li> Save the page and name it IndexServerTest.asp .</li></ol>

(back to top)

Step 3 - Add the Sample ASP Code to the Page
NOTE: You may receive an error message if you copy the examples directly from this article and paste them into FrontPage. The angle brackets may appear as escaped HTML code. To work around this behavior, paste the script into a blank Notepad document, and then copy it from Notepad before you paste it into FrontPage. <ol> Switch to HTML view.</li>  Type or paste the following code before the opening <HTML> tag: <% ' Force variable declaration. Option Explicit

' Declare all variables. Dim strQueryText Dim strQueryField Dim strSQL Dim strName Dim strValue Dim objRS Dim objField

' This is the list of index server variables that will appear. ' NOTE: You can customize the list of fields. For more information, ' see Microsoft Knowledge Base article Q288435. Const strDisplayFields = &quot;Rank, DocAuthor, DocAppName, DocTitle, FileName, Create, Access, Characterization, VPath&quot;

' This is the default index server catalog for all Web content. ' NOTE: For information about how to customize this, see Microsoft ' Knowledge Base article Q288435. Const strDataSource = &quot;WEB&quot;

' Get the value of the user-submitted search query. strQueryText = Request(&quot;QUERYTEXT&quot;) ' Set a default value if the user has not sumitted anything. If Len(strQueryText) = 0 Then strQueryText = &quot;N/A&quot;

' Get the field the user wants to query against. strQueryField = Request(&quot;QUERYFIELD&quot;) ' Set a default value if the user has not specified a field. If Len(strQueryField) = 0 Then strQueryField = &quot;DocTitle&quot; %>                   </li>  Type or paste the following code after the closing </FORM> tag: <% ' Build the SQL statement from the user-specified options. strSQL = &quot;SELECT &quot; & strDisplayFields & &quot; FROM SCOPE &quot; & _ &quot;WHERE ((&quot; & strQueryField & &quot; LIKE '%&quot; & strQueryText & &quot;%') AND &quot; & _   &quot;((VPath NOT LIKE '%/_vti%') AND (VPath NOT LIKE '%/_private%')))&quot;

' Create a recordset object. Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)

' Open the recordset using the SQL string with the index server provider. objRS.Open strSQL,&quot;PROVIDER=MSIDXS;DATA SOURCE=&quot; & strDataSource

' Are there any records to show? If objRS.EOF Then

' Show a default message if nothing was found. Response.Write &quot;No Documents were Found.&quot; & vbCrLf

' Otherwise... Else

' Start a table. Response.Write &quot;<table border=&quot;&quot;1&quot;&quot;>&quot; & vbCrLf

' Start the row for the header section. Response.Write &quot; &quot; & vbCrLf ' Loop through the fields collection. For Each objField in objRS.Fields ' Get the field's name. strName = objField.Name ' If the field has a name, escape it for HTML. If Len(strName) > 0 Then strName = Server.HTMLEncode(strName) ' Output the field name as a table header. Response.Write &quot; &quot; & strName & &quot; &quot; & vbCrLf Next ' End the row for the header section. Response.Write &quot; &quot; & vbCrLf

' Loop through all the records. While Not objRS.EOF ' Start a row in the data section. Response.Write &quot; &quot; & vbCrLf ' Loop through the fields collection. For Each objField in objRS.Fields ' Get the field's value. strValue = objField.Value ' Check for null values. If Len(strValue) > 0 Then ' If the value is not null, escape it for HTML. strValue = Server.HTMLEncode(strValue) Else ' Otherwise, make it a non-breaking space character. strValue = &quot;&#xa0;&quot; End If     ' Output the field value as table data. Response.Write &quot; &quot; & strValue & &quot; &quot; & vbCrLf Next ' End a row in the data section. Response.Write &quot; &quot; & vbCrLf ' Move to the next record. objRS.MoveNext Wend End If %> </li> Switch back to Normal view.</li> Save the file.</li></ol>

(back to top)

Step 4 - Test the Sample ASP Page

 * 1) In FrontPage, open the sample page.
 * 2) Click the Preview in Browser button on the Standard toolbar.
 * 3) Type some search criteria in the text box.
 * 4) From the drop-down menu, choose the field that you want to query.
 * 5) Click Submit.

Any results that match your query appear in a table on the page. (back to top)

Step 5 - Customize the Sample ASP Page
There are two customization options:
 * Changing the Catalog
 * Modifying the Field List

To Change the Catalog
If multiple Index Server catalogs are defined on your Web server, you can specify that the sample page use a different catalog. To do this, follow these steps: <ol> In FrontPage, open the sample page.</li> Switch to HTML view.</li>  Locate the following line of code: Const strDataSource = &quot;WEB&quot; </li> <li> Change the value of strDataSource to the name of your catalog, like this: Const strDataSource = &quot;MyCustomCatalog&quot; </li> <li>Save and close the file.</li></ol>

To Modify the Field List
<ol> <li>In FrontPage, open the sample page.</li> <li>Switch to HTML view.</li> <li> Locate the line that looks similar to this: Const strDisplayFields = &quot;Rank, DocAuthor, DocAppName&quot; </li> <li> Modify the list of values. Separate each field name with a comma, like this: Const strDisplayFields = &quot;Rank, DocAuthor, DocAppName, DocTitle&quot; </li> <li>Save and close the file.</li></ol>

The following table lists the values you can use for the strDisplayFields variable. <pre class="fixed_text"> Field Name             Field Type    Description --- Access                 Date/Time     Last time file was accessed.

Characterization       Text/String   Characterization, or abstract, of                                       document. Computed by Index Server.

Create                 Date/Time     Time file was created.

Directory              Text/String   Physical path to the file, not including the file name.

DocAppName             Text/String   Name of application that created the file.

DocAuthor              Text/String   Author of the document.

DocByteCount           Numeric       Number of bytes in the document.

DocCategory            Text/String   Type of document, such as a memo, schedule, or white paper.

DocCharCount           Numeric       Number of characters in the document.

DocComments            Text/String   Comments about the document.

DocCompany             Text/String   Name of the company for which the document was written.

DocCreatedTm           Date/Time     Time document was created.

DocEditTime            Date/Time     Total time spent editing document.

DocHiddenCount         Numeric       Number of hidden slides in a                                       PowerPoint file.

DocKeywords            Text/String   Document keywords.

DocLastAuthor          Text/String   Most recent user who edited the document.

DocLastPrinted         Date/Time     Time document was last printed.

DocLastSavedTm         Date/Time     Time document was last saved.

DocLineCount           Numeric       Number of lines contained in a                                       document.

DocManager             Text/String   Name of the manager of the document's                                      author.

DocNoteCount           Numeric       Number of pages with notes in a                                       PowerPoint file.

DocPageCount           Numeric       Number of pages in th document.

DocParaCount           Numeric       Number of paragraphs in the document.

DocPartTitles          Text/String   Names of document parts. For example, in Microsoft Excel, a spreadsheet is                                      a document part. In PowerPoint, a                                      slide is a document part. And, in                                      Word, the file names of the documents contained in a master document are document parts.

DocPresentationTarget  Text/String   Target format (35mm, printer, video,                                      and so on) for a PowerPoint presentation.

DocRevNumber           Text/String   Current version number of a document.

DocSlideCount          Numeric       Number of slides in a PowerPoint file.

DocSubject             Text/String   Subject of the document.

DocTemplate            Text/String   Name of the template for the document.

DocTitle               Text/String   Title of document.

DocWordCount           Numeric       Number of words in the document.

FileIndex              Numeric       Unique ID of the file.

FileName               Text/String   Name of the file.

HitCount               Numeric       Number of hits (words matching query) in the file.

Path                   Text/String   Full physical path to the file, including file name.

Rank                   Numeric       Rank of row. Ranges from 0 to 1000. Larger numbers indicate better matches.

ShortFileName          Text/String   Short (8.3) file name.

Size                   Numeric       Size of file, in bytes.

VPath                  Text/String   Full virtual path to file, including file name. If more than one possible path, then the best match for the specific query is chosen.

Write                  Date/Time     Last time file was written.

(back to top)

Troubleshooting
<ul> <li>If the Index Service is not running, the following error message appears:

Microsoft OLE DB Provider for Indexing Service error '80041820'

Service is not running.

/IndexServerTest.asp, line 44

To resolve this problem, start the Index Service.</li> <li>If you specify an invalid catalog, an error message similar to the following appears:

Microsoft OLE DB Provider for Indexing Service error '8004181d'

There is no catalog.

/IndexServerTest.asp, line 44

To resolve this problem, check the value of the strDataSource variable. If it is correct, restart the Index Service.</li></ul>

(back to top)

<div class="references_section">