Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript runtime error '800a01a8' -- Query.asp Index Server

Status
Not open for further replies.

corbitt

MIS
Feb 22, 2002
73
US
I'm new to ASP, and I'm trying to modify query.asp from the MS Platform SDK. I'm indexing PDFs. Query.asp works fine if there isn't more than one page of results. I get the following error when I click the 'Next 5 documents' button: " VBScript runtime error '800a01a8' Object required: '' /sdk/query.asp, line 322 "

I even tried executing query.asp without any modifications. It seems it has a problem right "out-of-the-box."

Can anyone see something I'm not seeing?

This is Line 320:

WebHitsQuery = WebHitsQuery & "&CiLocale=" & Util.LocaleIDToISO( Q.LocaleID )

Code:

<!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML 3.0//EN&quot; &quot;html.dtd&quot;>
<HTML>
<HEAD>
<%
' ********** INSTRUCTIONS FOR QUICK CUSTOMIZATION **********
'
' This form is set up for easy customization. It allows you to modify the
' page logo, the page background, the page title and simple query
' parameters by modifying a few files and form variables. The procedures
' to do this are explained below.
'
'
' *** Modifying the Form Logo:

' The logo for the form is named is2logo.gif. To change the page logo, simply
' name your logo is2logo.gif and place in the same directory as this form. If
' your logo is not a GIF file, or you don't want to copy it, change the following
' line so that the logo variable contains the URL to your logo.

FormLogo = &quot;is2logo.gif&quot;

'
' *** Modifying the Form's background pattern.

' You can use either a background pattern or a background color for your
' form. If you want to use a background pattern, store the file with the name
' is2bkgnd.gif in the same directory as this file and remove the remark character
' the single quote character) from the line below. Then put the remark character on
' the second line below.
'
' If you want to use a different background color than white, simply edit the
' bgcolor line below, replacing white with your color choice.

' FormBG = &quot;background = &quot; & chr(34) & &quot;is2bkgnd.gif&quot; & chr(34)
FormBG = &quot;bgcolor = &quot; & chr(34) & &quot;#FFFFFF&quot; & chr(34)


' *** Modifying the Form's Title Text.

' The Form's title text is set on the following line.

%>
<TITLE>Sample ASP Search Form</TITLE>
<%
'
' *** Modifying the Form's Search Scope.
'
' The form will search from the root of your web server's namespace and below
' (deep from &quot;/&quot; ). To search a subset of your server, for example, maybe just
' a PressReleases directory, modify the scope variable below to list the
' virtual path to search. The search will start at the directory you specify
' and include all sub-directories.

FormScope = &quot;/opinions/&quot;

'
' *** Modifying the Number of Returned Query Results.
'
' You can set the number of query results returned on a single page
' using the variable below.

PageSize = 10
'
' You can set the total number of query results returned using the
' variable below.

MaxResults = 300

'
' *** Setting the Locale.
'
' The following line sets the locale used for queries. In most cases, this
' should match the locale of the server. You can set the locale below.

SiteLocale = &quot;EN-US&quot;

'
' *** Enable saving active searches in session variables
'
' The following line enables using session state to save multi-page queries
' and avoid re-executing them when the user presses the Next Page button.
' This should be set FALSE if sessions are disabled using AspAllowSessionState.

UseSessions = TRUE

' ********** END QUICK CUSTOMIZATION SECTIONS ***********
%>

<LINK REL=STYLESHEET HREF=&quot;is2style.css&quot; TYPE=&quot;text/css&quot;>

<META NAME=&quot;DESCRIPTION&quot; CONTENT=&quot;Sample ASP query form for Indexing Service&quot;>
<META NAME=&quot;AUTHOR&quot; CONTENT=&quot;Indexing Service Team&quot;>
<META NAME=&quot;KEYWORDS&quot; CONTENT=&quot;query, content, hit&quot;>
<META NAME=&quot;SUBJECT&quot; CONTENT=&quot;sample form&quot;>
<META NAME=&quot;MS.CATEGORY&quot; CONTENT=&quot;Internet&quot;>
<META NAME=&quot;MS.LOCALE&quot; CONTENT=&quot;EN-US&quot;>
<META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=Windows-1252&quot;>
<%
' Set Initial Conditions
NewQuery = FALSE
UseSavedQuery = FALSE
SearchString = &quot;&quot;

QueryForm = Request.ServerVariables(&quot;PATH_INFO&quot;)

' Did the user press a SUBMIT button to execute the form? If so get the form variables.
if Request.ServerVariables(&quot;REQUEST_METHOD&quot;) = &quot;POST&quot; then
SearchString = Request.Form(&quot;SearchString&quot;)
Advanced = Request.Form(&quot;Advanced&quot;)
' NOTE: this will be true only if the button is actually pushed.
if Request.Form(&quot;Action&quot;) = &quot;Go&quot; then
NewQuery = TRUE
RankBase=1000
NextPageNumber = -1
end if
end if
if Request.ServerVariables(&quot;REQUEST_METHOD&quot;) = &quot;GET&quot; then
SearchString = Request.QueryString(&quot;qu&quot;)
Advanced = Request.QueryString(&quot;Advanced&quot;)
FormScope = Request.QueryString(&quot;sc&quot;)
RankBase = Request.QueryString(&quot;RankBase&quot;)
if Request.QueryString(&quot;pg&quot;) <> &quot;&quot; then
NextPageNumber = Request.QueryString(&quot;pg&quot;)
UseSavedQuery = UseSessions
NewQuery = not UseSessions
else
NewQuery = SearchString <> &quot;&quot;
NextPageNumber = -1
end if
end if
%>
</HEAD>

<BODY OnLoad=&quot;Init()&quot; LANGUAGE=&quot;JSCRIPT&quot; <%=FormBG%>>

<TABLE>
<TR><TD><A HREF=&quot; target=&quot;_top&quot;><IMG SRC =&quot;<%=FormLogo%>&quot; border=0 VALIGN=MIDDLE ALIGN=LEFT></a></TD></TR>
<TR><TD ALIGN=&quot;RIGHT&quot;><H3>Sample ASP Search Form</H3></TD></TR>
</TABLE>

<p>

<FORM NAME=QueryForm ACTION=&quot;<%=QueryForm%>&quot; METHOD=POST>
<TABLE WIDTH=500>
<TR>
<TD>Enter your query below:</TD>
</TR>
<TR>
<TD><INPUT TYPE=&quot;TEXT&quot; NAME=&quot;SearchString&quot; SIZE=&quot;65&quot; MAXLENGTH=&quot;100&quot; VALUE=&quot;<%=SearchString%>&quot; TABINDEX=1></TD>
<TD><BUTTON TYPE=SUBMIT NAME=&quot;Action&quot;>Go</BUTTON></TD>
</TR>
<TR>
<TD ALIGN=&quot;RIGHT&quot;><A HREF=&quot;ixtiphlp.htm&quot;>Tips for searching</A></TD>
</TR>
<TR>
</TR>
<TR>
<TD><INPUT NAME=&quot;Advanced&quot; TYPE=CHECKBOX<% if Advanced = &quot;on&quot; then Response.Write(&quot; CHECKED&quot;) end if %>>
Use <a href=&quot;ixtiphlp.htm&quot;>Advanced Query</a>.
</TD>
</TR>
</TABLE>
</FORM>

<BR>

<%
if NewQuery then
if UseSessions then
set Session(&quot;Query&quot;) = nothing
set Session(&quot;Recordset&quot;) = nothing
end if
NextRecordNumber = 1

' Remove any leading and ending quotes from SearchString

SrchStrLen = len(SearchString)

if left(SearchString, 1) = chr(34) then
SrchStrLen = SrchStrLen-1
SearchString = right(SearchString, SrchStrLen)
end if

if right(SearchString, 1) = chr(34) then
SrchStrLen = SrchStrLen-1
SearchString = left(SearchString, SrchStrLen)
end if

if Advanced<> &quot;on&quot; then
CompSearch = &quot;{freetext} &quot; & SearchString & &quot;{/freetext}&quot;
else
CompSearch = SearchString
end if

set Q = Server.CreateObject(&quot;ixsso.Query&quot;)
set Util = Server.CreateObject(&quot;ixsso.Util&quot;)

Q.Catalog = &quot;web&quot;
Q.Query = CompSearch
Q.SortBy = &quot;rank[d]&quot;
Q.Columns = &quot;DocTitle, vpath, filename, size, write, characterization, rank&quot;

if MaxResults <> -1 then
Q.MaxRecords = MaxResults
end if

if FormScope <> &quot;\&quot; then
Util.AddScopeToQuery Q, FormScope, &quot;deep&quot;
end if

if SiteLocale <> &quot;&quot; then
Q.LocaleID = Util.ISOToLocaleID(SiteLocale)
end if

set RS = Q.CreateRecordSet(&quot;nonsequential&quot;)

RS.PageSize = PageSize
RS.CacheSize = PageSize
ActiveQuery = TRUE

elseif UseSavedQuery then
if IsObject( Session(&quot;Query&quot;) ) And IsObject( Session(&quot;RecordSet&quot;) ) then
set Q = Session(&quot;Query&quot;)
set RS = Session(&quot;RecordSet&quot;)

ActiveQuery = TRUE
else
Response.Write &quot;ERROR - No saved query&quot;
end if
end if

if ActiveQuery then
if RS.RecordCount <> -1 and NextPageNumber <> -1 then
RS.AbsolutePage = NextPageNumber
NextRecordNumber = RS.AbsolutePosition
end if

if not RS.EOF then
%>

<p>
<HR WIDTH=80% ALIGN=center SIZE=3>
<p>

<%
LastRecordOnPage = NextRecordNumber + RS.PageSize - 1
CurrentPage = RS.AbsolutePage
if RS.RecordCount <> -1 AND RS.RecordCount < LastRecordOnPage then
LastRecordOnPage = RS.RecordCount
end if

Response.Write &quot;Documents &quot; & NextRecordNumber & &quot; to &quot; & LastRecordOnPage
if RS.RecordCount <> -1 then
Response.Write &quot; of &quot; & RS.RecordCount
end if
Response.Write &quot; matching the query &quot; & chr(34) & &quot;<I>&quot;
Response.Write Server.HTMLEncode( SearchString ) & &quot;</I>&quot; & chr(34) & &quot;.<P>&quot;
%>

<% if Not RS.EOF and NextRecordNumber <= LastRecordOnPage then%>
<table border=0>
<colgroup width=105>
<% end if %>

<% Do While Not RS.EOF and NextRecordNumber <= LastRecordOnPage

' This is the detail portion for Title, Abstract, URL, Size, and
' Modification Date.

' If there is a title, display it, otherwise display the filename.
%>
<p>
<%
' Graphically indicate rank of document with list of stars (*'s).

if NextRecordNumber = 1 then
RankBase=RS(&quot;rank&quot;)
end if

if RankBase>1000 then
RankBase=1000
elseif RankBase<1 then
RankBase=1
end if

NormRank = RS(&quot;rank&quot;)/RankBase

if NormRank > 0.80 then
stars = &quot;rankbtn5.gif&quot;
elseif NormRank > 0.60 then
stars = &quot;rankbtn4.gif&quot;
elseif NormRank > 0.40 then
stars = &quot;rankbtn3.gif&quot;
elseif NormRank >.20 then
stars = &quot;rankbtn2.gif&quot;
else
stars = &quot;rankbtn1.gif&quot;
end if
%>
<tr class=&quot;RecordTitle&quot;>
<td align=&quot;right&quot; valign=top class=&quot;RecordTitle&quot;>
<%= NextRecordNumber%>.
</td>
<td><b class=&quot;RecordTitle&quot;>
<%if VarType(RS(&quot;DocTitle&quot;)) = 1 or RS(&quot;DocTitle&quot;) = &quot;&quot; then%>
<a href=&quot;javascript:NAF(' class=&quot;RecordTitle&quot;><%= Server.HTMLEncode( RS(&quot;filename&quot;) )%></a>
<%else%>
<a href=&quot;javascript:NAF(' class=&quot;RecordTitle&quot;><%= Server.HTMLEncode(RS(&quot;DocTitle&quot;))%></a>
<%end if%>
</b></td>
</tr>

<tr>
<td valign=top align=left>
<IMG SRC=&quot;<%=stars%>&quot;>
<br>
<%
' Construct the URL for hit highlighting
WebHitsQuery = &quot;CiWebHitsFile=&quot; & Server.URLEncode( RS(&quot;vpath&quot;) )
WebHitsQuery = WebHitsQuery & &quot;&CiRestriction=&quot; & Server.URLEncode( Q.Query )
WebHitsQuery = WebHitsQuery & &quot;&CiUserParam3=&quot; & QueryForm
WebHitsQuery = WebHitsQuery & &quot;&CiLocale=&quot; & Util.LocaleIDToISO( Q.LocaleID )
%>
<a href=&quot;qsumrhit.htw?<%= WebHitsQuery %>&quot;>
<IMG src=&quot;hilight.gif&quot; align=left alt=&quot;Highlight matching terms in document using Summary mode.&quot;> Summary</a>
<br>
<a href=&quot;qfullhit.htw?<%= WebHitsQuery %>&CiHiliteType=Full&quot;>
<IMG src=&quot;hilight.gif&quot; align=left alt=&quot;Highlight matching terms in document.&quot;> Full</a>
</td>
<td valign=top>
<%if VarType(RS(&quot;characterization&quot;)) = 8 and RS(&quot;characterization&quot;) <> &quot;&quot; then%>
<b><i>Abstract: </i></b>
<%= Server.HTMLEncode(RS(&quot;characterization&quot;))%>
<%end if%>
<p>
<i class=&quot;RecordStats&quot;><a href=&quot;javascript:NAF(' class=&quot;RecordStats&quot; style=&quot;color:blue;&quot;> <br><%if RS(&quot;size&quot;) = &quot;&quot; then%>(size and time unknown)<%else%>size <%=RS(&quot;size&quot;)%> bytes - <%=RS(&quot;write&quot;)%> GMT<%end if%></i>
</td>
</tr>
<tr>
</tr>
<%
RS.MoveNext
NextRecordNumber = NextRecordNumber+1
Loop
%>

</table>
<P><BR>

<%
else ' NOT RS.EOF
if NextRecordNumber = 1 then
Response.Write &quot;No documents matched the query<P>&quot;
else
Response.Write &quot;No more documents in the query<P>&quot;
end if

end if ' NOT RS.EOF


if NOT Q.OutOfDate then
' If the index is current, display the fact %>
<P>
<I><B>The index is up to date.</B></I><BR>
<%end if


if Q.QueryIncomplete then
' If the query was not executed because it needed to enumerate to
' resolve the query instead of using the index, but AllowEnumeration
' was FALSE, let the user know
%>
<P>
<I><B>The query is too expensive to complete.</B></I><BR>
<%end if


if Q.QueryTimedOut then
' If the query took too long to execute (for example, if too much work
' was required to resolve the query), let the user know %>
<P>
<I><B>The query took too long to complete.</B></I><BR>
<%end if%>

<TABLE>

<%
' This is the &quot;previous&quot; button.
' This retrieves the previous page of documents for the query.

SaveQuery = FALSE
if CurrentPage > 1 and RS.RecordCount <> -1 then %>
<td align=left>
<form action=&quot;<%=QueryForm%>&quot; method=&quot;get&quot;>
<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;qu&quot; VALUE=&quot;<%=SearchString%>&quot;>
<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;Advanced&quot; VALUE=&quot;<%=Advanced%>&quot;>
<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;sc&quot; VALUE=&quot;<%=FormScope%>&quot;>
<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;pg&quot; VALUE=&quot;<%=CurrentPage-1%>&quot; >
<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;RankBase&quot; VALUE=&quot;<%=RankBase%>&quot;>
<input type=&quot;submit&quot; value=&quot;Previous <%=RS.PageSize%> documents&quot;>
</form>
</td>
<%SaveQuery = UseSessions%>
<%end if%>

<%
' This is the &quot;next&quot; button for unsorted queries.
' This retrieves the next page of documents for the query.

if Not RS.EOF then%>
<td align=right>
<form action=&quot;<%=QueryForm%>&quot; method=&quot;get&quot;>
<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;qu&quot; VALUE=&quot;<%=SearchString%>&quot;>
<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;Advanced&quot; VALUE=&quot;<%=Advanced%>&quot;>
<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;sc&quot; VALUE=&quot;<%=FormScope%>&quot;>
<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;pg&quot; VALUE=&quot;<%=CurrentPage+1%>&quot;>
<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;RankBase&quot; VALUE=&quot;<%=RankBase%>&quot;>
<%
NextString = &quot;Next &quot;
if RS.RecordCount <> -1 then
NextSet = (RS.RecordCount - NextRecordNumber) + 1
if NextSet > RS.PageSize then
NextSet = RS.PageSize
end if
NextString = NextString & NextSet & &quot; documents&quot;
else
NextString = NextString & &quot; page of documents&quot;
end if
%>
<input type=&quot;submit&quot; value=&quot;<%=NextString%>&quot;>
</form>
</td>
<%SaveQuery = UseSessions%>
<%end if%>

</TABLE>

<% ' Display the page number

if RS.PageCount <> 0 then
Response.Write &quot;Page &quot; & CurrentPage
if RS.PageCount <> -1 then
Response.Write &quot; of &quot; & RS.PageCount
end if
end if
%>
<%
' If either of the previous or back buttons were displayed, save the query
' and the recordset in session variables.
if SaveQuery then
set Session(&quot;Query&quot;) = Q
set Session(&quot;RecordSet&quot;) = RS
else
RS.close
Set RS = Nothing
Set Q = Nothing
set Util = nothing
if UseSessions then
set Session(&quot;Query&quot;) = Nothing
set Session(&quot;RecordSet&quot;) = Nothing
end if
end if
%>
<% end if %>
<BR>

</BODY>

<SCRIPT LANGUAGE=JSCRIPT>
function Init()
{
QueryForm.SearchString.focus();
}

function msieversion()
{
var ua = window.navigator.userAgent;
var msie = ua.indexOf(&quot;MSIE&quot;);
if (msie>0)
return parseInt(ua.substring(msie+5, ua.indexOf(&quot;.&quot;, msie)));
else
return 0;
}

function NAF(szUrl, szQuery)
{
if (msieversion() >= 5)
window.external.NavigateAndFind(szUrl, szQuery, &quot;_main&quot;);
else
window.navigate(szUrl, target=&quot;_main&quot;);
}
</SCRIPT>

</HTML>



Thank you,

Jeremy
 
I figured it out! Solution: I set UseSessions = FALSE

JC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top