Microsoft KB Archive/318387

= How to query Index Server data by using ASP in FrontPage 2002 =

Article ID: 318387

Article Last Modified on 2/1/2007

-

APPLIES TO


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

-



This article was previously published under Q318387







For a Microsoft FrontPage 2000 version of this article, see 288435.



For a Microsoft FrontPage 2003 version of this article, see 825487.

IN THIS TASK

 * SUMMARY
 * Step 1 - Prepare to Use the ASP Features in FrontPage
 * Step 2 - Create a Form Page in FrontPage
 * Step 3 - Add the Sample ASP Code to the Page
 * Step 4 - Test the Sample ASP Page
 * Step 5 - Customize the Sample ASP Page
 * Troubleshooting
 * REFERENCES



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

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 2002, install the components listed in the following Microsoft Knowledge Base article:

318287 What you need to use Active Server Pages (ASP) in FrontPage 2002

(back to top)

Step 2 - Create a Form Page in FrontPage
 Start FrontPage and then open a Web site on a Microsoft Windows 2000 Web Server. Click the New Page button on the Standard toolbar. On the Insert menu, point to Form, and then click Textbox.  Double-click the text box. Name it QUERYTEXT. For the initial value, type: <%=Request(&quot;QUERYTEXT&quot;)%> Click OK.  Click after the text box.</li> Add a drop-down list box to the form. To do this, point to Form on the Insert menu, and then click Drop-Down Box.</li> Double-click the drop-down list box. Name it 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 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 our 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 Q318387. 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 Q318387.

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 is found. Response.Write &quot;No Documents were Found.&quot; & vbCrLf

' Otherwise... Else

' Start a table. Response.Write &quot; &quot; & vbCrLf 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) Open the sample page in FrontPage.
 * 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> <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, similar to 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 of code 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">