473,288 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

asp query form

Hi,

I try to write an asp query form that lets client search any text-string and
display all pages in my web server that contain the text. I have IIS 6.0 on a
server 2003. The MSDN site says there is a sample file called Ixtrasp.asp,
but I could not find it in my system although I installed indexing service. I
followed the steps in MSDN site to create a basic .asp query form (too long
to post it here), but it always displays:

No documents matched the query

The index is out of date.
Page of 0

Under the computer's manager -- indexing services -- web, the "Query the
Catalog" works, displaying all pages in my web server that contain the
searching text.

Can somebody help me? either tell me where to find Ixtrasp.asp, or any
similar sample asp page for searching text-string in the web pages (not
search in database)?

Thanks!

Harvey
Jul 21 '05 #1
3 5348
Post the relevant code. You should be able to create a reproducible page
with only a few lines of code.

Jeff

"Harvey" <Ha****@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
Hi,

I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says there is a sample file called Ixtrasp.asp, but I could not find it in my system although I installed indexing service. I followed the steps in MSDN site to create a basic .asp query form (too long to post it here), but it always displays:

No documents matched the query

The index is out of date.
Page of 0

Under the computer's manager -- indexing services -- web, the "Query the
Catalog" works, displaying all pages in my web server that contain the
searching text.

Can somebody help me? either tell me where to find Ixtrasp.asp, or any
similar sample asp page for searching text-string in the web pages (not
search in database)?

Thanks!

Harvey

Jul 21 '05 #2
I believe there must be a simple code to do it. But, I just haven't found it.
Here is the code that I copied from MSDN web site:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd">
<HTML>
<HEAD>
<SCRIPT LANGUAGE="VBScript" RUNAT="Server"> </SCRIPT>
<TITLE>Index Server Search Form</TITLE>
<META NAME="DESCRIPTION" CONTENT="Sample ASP query form for Microsoft
Index Server">
<META NAME="KEYWORDS" CONTENT="query, content, hit, asp">
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=Windows-1252">
<%
NewQuery = FALSE
UseSavedQuery = FALSE
QueryForm = Request.ServerVariables( "PATH_INFO" )
SearchString = ""
if Request.ServerVariables("REQUEST_METHOD") = "POST" then
SearchString = Request.Form("SearchString")
pg = Request.Form("pg")
if pg <> "" then
NextPageNumber = pg
NewQuery = FALSE
UseSavedQuery = TRUE
else
NewQuery = SearchString <> ""
end if
end if
%>
</HEAD>

<TABLE>
<TR> <TD><H1>Sample ASP Search Form</H1></TD> </TR>
</TABLE>

<HR WIDTH=75% ALIGN=center SIZE=3>
<p>
<TABLE>
<TR> <TD ALIGN=LEFT>Enter your query below:</TD> </TR>
<TR>
<TD>
<FORM ACTION="<%= QueryForm%>" METHOD=POST>
<TABLE> <TR>
<TD><INPUT TYPE="TEXT" NAME="SearchString" SIZE="60"
MAXLENGTH="100" VALUE="<%=SearchString%>"></TD>
<TD><INPUT TYPE="SUBMIT" NAME="Action" VALUE="New Query"></TD>
</TR>
</TABLE>
</FORM>
</TD>
</TR>
</TABLE>
<BR>
<%
if SearchString <> "" then
if NewQuery then
set Session("Query") = nothing
set Session("Recordset") = nothing
NextRecordNumber = 1

set Q = Server.CreateObject("ixsso.Query")
set util = Server.CreateObject("ixsso.util")
Q.Query = SearchString
Q.SortBy = "rank[d]"
Q.Columns = "DocTitle, vpath, path, filename, size, write,
characterization"
util.AddScopeToQuery Q, "/Myfiles", "deep"

set RS = Q.CreateRecordSet("nonsequential")

RS.PageSize = 10
ActiveQuery = TRUE

elseif UseSavedQuery then
if IsObject( Session("Query") ) And IsObject( Session("RecordSet") ) then
set Q = Session("Query")
set RS = Session("RecordSet")

if RS.RecordCount <> -1 and NextPageNumber <> -1 then
RS.AbsolutePage = NextPageNumber
NextRecordNumber = RS.AbsolutePosition
end if
ActiveQuery = TRUE
else
Response.Write "ERROR - No saved query"
end if
end if
%>
<%
if ActiveQuery then
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 "Documents " & NextRecordNumber & " to " &
LastRecordOnPage
if RS.RecordCount <> -1 then
Response.Write " of " & RS.RecordCount
end if
Response.Write " matching the query " & chr(34) & "<I>"
Response.Write SearchString & "</I>" & chr(34) & ".<P>"
%>
<dl>
<!-- BEGIN first row of query results table -->
<% 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 virtual path.
%>
<p>
<dt><%= NextRecordNumber%>.
<%if VarType(RS("DocTitle")) = 1 or RS("DocTitle") = "" then%>
<b><a href="<%=RS("vpath")%>"><%= Server.HTMLEncode(
RS("filename") )%></a></b>
<%else%>
<b><a href="<%=RS("vpath")%>"><%=
Server.HTMLEncode(RS("DocTitle"))%></a></b>
<%end if%>
<dd>
<%if VarType(RS("characterization")) = 8 and RS("characterization")
<> "" then%>
<b><i>Abstract: </I></b><%=
Server.HTMLEncode(RS("characterization"))%>
<br>
<%end if%>
<cite>
<a
href="<%=RS("vpath")%>">http://<%=Request("server_name")%><%=RS("vpath")%></a>
<font size=-1> - <%if RS("size") = "" then%>(size and time
unknown)<%else%>size <%=RS("size")%> bytes - <%=RS("write")%> GMT<%end
if%></font>
</cite>
<%
RS.MoveNext
NextRecordNumber = NextRecordNumber+1
Loop
%>
</dl>
<P><BR>
<%
else ' NOT RS.EOF
if NextRecordNumber = 1 then
Response.Write "No documents matched the query<P>"
else
Response.Write "No more documents in the query<P>"
end if

end if ' NOT RS.EOF
%>
<!-- If the index is out of date, display the fact -->
<%if Q.OutOfDate then%>
<P>
<I><B>The index is out of date.</B></I><BR>
<%end if%>
<!--
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
-->
<%if Q.QueryIncomplete then%>
<P>
<I><B>The query is too expensive to complete.</B></I><BR>
<%end if%>
<!--
If the query took too long to execute (for example, if too much work
was required to resolve the query), let the user know
-->
<%if Q.QueryTimedOut then%>
<P>
<I><B>The query took too long to complete.</B></I><BR>
<%end if%>
<TABLE>
<!--
This is the "previous" 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="<%= QueryForm%>" method="POST">
<INPUT TYPE="HIDDEN" NAME="SearchString"
VALUE="<%=SearchString%>">
<INPUT TYPE="HIDDEN" name="pg" VALUE="<%=CurrentPage-1%>" >

<input type="submit" value="Previous <%=RS.PageSize%> documents">
</form>
</td>
<%SaveQuery = TRUE%>
<%end if%>
<!--
This is the "next" button.
This button retrieves the next page of documents for the query.
If the RS.RecordCount is available, the number of
documents on the next page will be displayed.
-->
<%if Not RS.EOF then%>
<td align=right>
<form action="<%= QueryForm%>" method="POST">
<INPUT TYPE="HIDDEN" NAME="SearchString"
VALUE="<%=SearchString%>">
<INPUT TYPE="HIDDEN" name="pg" VALUE="<%=CurrentPage+1%>" >
<% NextString = "Next "
if RS.RecordCount <> -1 then
NextSet = (RS.RecordCount - NextRecordNumber) + 1
if NextSet > RS.PageSize then
NextSet = RS.PageSize
end if
NextString = NextString & NextSet & " documents"
else
NextString = NextString & " page of documents"
end if
%>
<input type="submit" value="<%=NextString%>">
</form>
</td>
<%SaveQuery = TRUE%>
<%end if%>
</TABLE>

<!-- Display the page number -->
Page <%=CurrentPage%><%if RS.PageCount <> -1 then
Response.Write " of " & RS.PageCount
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("Query") = Q
set Session("RecordSet") = RS
else
RS.close
Set RS = Nothing
Set Q = Nothing
set Session("Query") = Nothing
set Session("RecordSet") = Nothing
end if
%><% end if
elseif not NewQuery then
Response.Write ""
else
Response.Write "Please enter a word or phrase to search for."
end if
%></html>
"Jeff Dillon" wrote:
Post the relevant code. You should be able to create a reproducible page
with only a few lines of code.

Jeff

"Harvey" <Ha****@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
Hi,

I try to write an asp query form that lets client search any text-string

and
display all pages in my web server that contain the text. I have IIS 6.0

on a
server 2003. The MSDN site says there is a sample file called

Ixtrasp.asp,
but I could not find it in my system although I installed indexing

service. I
followed the steps in MSDN site to create a basic .asp query form (too

long
to post it here), but it always displays:

No documents matched the query

The index is out of date.
Page of 0

Under the computer's manager -- indexing services -- web, the "Query the
Catalog" works, displaying all pages in my web server that contain the
searching text.

Can somebody help me? either tell me where to find Ixtrasp.asp, or any
similar sample asp page for searching text-string in the web pages (not
search in database)?

Thanks!

Harvey


Jul 21 '05 #3
Sorry, I won't go through that much code. Forget about the POST and
variables...hard code everything.

Reduce the number of lines to 10 or so...

Jeff

"Harvey" <Ha****@discussions.microsoft.com> wrote in message
news:DE**********************************@microsof t.com...
I believe there must be a simple code to do it. But, I just haven't found it. Here is the code that I copied from MSDN web site:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd">
<HTML>
<HEAD>
<SCRIPT LANGUAGE="VBScript" RUNAT="Server"> </SCRIPT>
<TITLE>Index Server Search Form</TITLE>
<META NAME="DESCRIPTION" CONTENT="Sample ASP query form for Microsoft
Index Server">
<META NAME="KEYWORDS" CONTENT="query, content, hit, asp">
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=Windows-1252">
<%
NewQuery = FALSE
UseSavedQuery = FALSE
QueryForm = Request.ServerVariables( "PATH_INFO" )
SearchString = ""
if Request.ServerVariables("REQUEST_METHOD") = "POST" then
SearchString = Request.Form("SearchString")
pg = Request.Form("pg")
if pg <> "" then
NextPageNumber = pg
NewQuery = FALSE
UseSavedQuery = TRUE
else
NewQuery = SearchString <> ""
end if
end if
%>
</HEAD>

<TABLE>
<TR> <TD><H1>Sample ASP Search Form</H1></TD> </TR>
</TABLE>

<HR WIDTH=75% ALIGN=center SIZE=3>
<p>
<TABLE>
<TR> <TD ALIGN=LEFT>Enter your query below:</TD> </TR>
<TR>
<TD>
<FORM ACTION="<%= QueryForm%>" METHOD=POST>
<TABLE> <TR>
<TD><INPUT TYPE="TEXT" NAME="SearchString" SIZE="60"
MAXLENGTH="100" VALUE="<%=SearchString%>"></TD>
<TD><INPUT TYPE="SUBMIT" NAME="Action" VALUE="New Query"></TD>
</TR>
</TABLE>
</FORM>
</TD>
</TR>
</TABLE>
<BR>
<%
if SearchString <> "" then
if NewQuery then
set Session("Query") = nothing
set Session("Recordset") = nothing
NextRecordNumber = 1

set Q = Server.CreateObject("ixsso.Query")
set util = Server.CreateObject("ixsso.util")
Q.Query = SearchString
Q.SortBy = "rank[d]"
Q.Columns = "DocTitle, vpath, path, filename, size, write,
characterization"
util.AddScopeToQuery Q, "/Myfiles", "deep"

set RS = Q.CreateRecordSet("nonsequential")

RS.PageSize = 10
ActiveQuery = TRUE

elseif UseSavedQuery then
if IsObject( Session("Query") ) And IsObject( Session("RecordSet") ) then set Q = Session("Query")
set RS = Session("RecordSet")

if RS.RecordCount <> -1 and NextPageNumber <> -1 then
RS.AbsolutePage = NextPageNumber
NextRecordNumber = RS.AbsolutePosition
end if
ActiveQuery = TRUE
else
Response.Write "ERROR - No saved query"
end if
end if
%>
<%
if ActiveQuery then
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 "Documents " & NextRecordNumber & " to " &
LastRecordOnPage
if RS.RecordCount <> -1 then
Response.Write " of " & RS.RecordCount
end if
Response.Write " matching the query " & chr(34) & "<I>"
Response.Write SearchString & "</I>" & chr(34) & ".<P>"
%>
<dl>
<!-- BEGIN first row of query results table -->
<% 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 virtual path.
%>
<p>
<dt><%= NextRecordNumber%>.
<%if VarType(RS("DocTitle")) = 1 or RS("DocTitle") = "" then%>
<b><a href="<%=RS("vpath")%>"><%= Server.HTMLEncode(
RS("filename") )%></a></b>
<%else%>
<b><a href="<%=RS("vpath")%>"><%=
Server.HTMLEncode(RS("DocTitle"))%></a></b>
<%end if%>
<dd>
<%if VarType(RS("characterization")) = 8 and RS("characterization") <> "" then%>
<b><i>Abstract: </I></b><%=
Server.HTMLEncode(RS("characterization"))%>
<br>
<%end if%>
<cite>
<a
href="<%=RS("vpath")%>">http://<%=Request("server_name")%><%=RS("vpath")%></
a> <font size=-1> - <%if RS("size") = "" then%>(size and time
unknown)<%else%>size <%=RS("size")%> bytes - <%=RS("write")%> GMT<%end
if%></font>
</cite>
<%
RS.MoveNext
NextRecordNumber = NextRecordNumber+1
Loop
%>
</dl>
<P><BR>
<%
else ' NOT RS.EOF
if NextRecordNumber = 1 then
Response.Write "No documents matched the query<P>"
else
Response.Write "No more documents in the query<P>"
end if

end if ' NOT RS.EOF
%>
<!-- If the index is out of date, display the fact -->
<%if Q.OutOfDate then%>
<P>
<I><B>The index is out of date.</B></I><BR>
<%end if%>
<!--
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
-->
<%if Q.QueryIncomplete then%>
<P>
<I><B>The query is too expensive to complete.</B></I><BR>
<%end if%>
<!--
If the query took too long to execute (for example, if too much work
was required to resolve the query), let the user know
-->
<%if Q.QueryTimedOut then%>
<P>
<I><B>The query took too long to complete.</B></I><BR>
<%end if%>
<TABLE>
<!--
This is the "previous" 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="<%= QueryForm%>" method="POST">
<INPUT TYPE="HIDDEN" NAME="SearchString"
VALUE="<%=SearchString%>">
<INPUT TYPE="HIDDEN" name="pg" VALUE="<%=CurrentPage-1%>" >

<input type="submit" value="Previous <%=RS.PageSize%> documents"> </form>
</td>
<%SaveQuery = TRUE%>
<%end if%>
<!--
This is the "next" button.
This button retrieves the next page of documents for the query.
If the RS.RecordCount is available, the number of
documents on the next page will be displayed.
-->
<%if Not RS.EOF then%>
<td align=right>
<form action="<%= QueryForm%>" method="POST">
<INPUT TYPE="HIDDEN" NAME="SearchString"
VALUE="<%=SearchString%>">
<INPUT TYPE="HIDDEN" name="pg" VALUE="<%=CurrentPage+1%>" >
<% NextString = "Next "
if RS.RecordCount <> -1 then
NextSet = (RS.RecordCount - NextRecordNumber) + 1
if NextSet > RS.PageSize then
NextSet = RS.PageSize
end if
NextString = NextString & NextSet & " documents"
else
NextString = NextString & " page of documents"
end if
%>
<input type="submit" value="<%=NextString%>">
</form>
</td>
<%SaveQuery = TRUE%>
<%end if%>
</TABLE>

<!-- Display the page number -->
Page <%=CurrentPage%><%if RS.PageCount <> -1 then
Response.Write " of " & RS.PageCount
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("Query") = Q
set Session("RecordSet") = RS
else
RS.close
Set RS = Nothing
Set Q = Nothing
set Session("Query") = Nothing
set Session("RecordSet") = Nothing
end if
%><% end if
elseif not NewQuery then
Response.Write ""
else
Response.Write "Please enter a word or phrase to search for."
end if
%></html>
"Jeff Dillon" wrote:
Post the relevant code. You should be able to create a reproducible page
with only a few lines of code.

Jeff

"Harvey" <Ha****@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
Hi,

I try to write an asp query form that lets client search any text-string
and
display all pages in my web server that contain the text. I have IIS
6.0 on a
server 2003. The MSDN site says there is a sample file called

Ixtrasp.asp,
but I could not find it in my system although I installed indexing

service. I
followed the steps in MSDN site to create a basic .asp query form (too

long
to post it here), but it always displays:

No documents matched the query

The index is out of date.
Page of 0

Under the computer's manager -- indexing services -- web, the "Query

the Catalog" works, displaying all pages in my web server that contain the
searching text.

Can somebody help me? either tell me where to find Ixtrasp.asp, or any
similar sample asp page for searching text-string in the web pages (not search in database)?

Thanks!

Harvey


Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: MX1 | last post by:
I have a query written in MS Access that has a few calculated fields. Is it possible to refer to that query in a form field. I'd like the form field to show the sum of one of the columns from the...
3
by: Steve | last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's criteria is set ats: Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the selections are 30, 60...
1
by: Nicolae Fieraru | last post by:
Hi All, I want to find if there is a different way than the way I am working now. Lets say I have a table, tblCustomers containing address details. I want a report with all the customers from...
6
by: Brian | last post by:
Hello, Basically, I'm running a query on a form's activation, and I'd like to have the results of the query be placed into other fields on the same form automatically. Does anybody know how...
13
by: Lee | last post by:
Hello All, First of all I would like to say thank you for all of the help I have received here. I have been teaching myself Access for about 4 years now and I've always been able to find a...
3
by: rhobson2 | last post by:
Hello, I wrote a database applicaiton using Access XP (2002) and everything has been working good for the client until they purchased a couple of new computers with Access 2003. The meetings...
1
by: bgreenspan | last post by:
Hi Everyone, I'm back for some more expert help. Here's what I am doing and what I tried. My database has entries with Contract Names and Expiry Dates, among other fields. I have a form...
3
by: pbd22 | last post by:
Hi. I need some help with structuring my query strings. I have a form with a search bar and some links. Each link is a search type (such as "community"). The HREF for the link's anchor looks...
2
by: lindabaldwin | last post by:
Hello everyone, I am fairly new to VBA. I have a worksheet in Excel, named "Data Sheet" from which I am trying to query data. This worksheet contains the following data: unit (column A), date...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.