Summary: The full text of the word search is the method of the browser, and the ASP is similar to CGI, and it can also perform a simple text.
Keywords: ASP search intranet page ADO data source
What is often touched in the Internet / Intranet on a detailed browsing and full-text search. ASP is a server-side that Microsoft developed for making dynamic web pages
Script type (or write a environment). It uses VBScript or JavaScript and other simple script languages, integrated in the HTML code, executes the data visit in the server side responds to the browser request.
Question and process (or object) call and generate the scripting language executed by the browser. This article describes the method of writing a full text search code with ASP.
Method introduction:
Determine the retrieved file. Save them in the same folder. The type of file can be any text type (including .htm web file type)
Build a library that is retrieved. It mainly includes file name, file title, etc.
Access the database in ADO. Establish a recordset object.
Open the file points to the current record in the recordset one by one. Match the full text of the file with the string of the lookup.
Output the eligible file header to the client web page and add a chain pointing to the file for users to choose to browse.
Technical points:
data source. To specify the database and its driver to be accessed using the ODBC in the Windows 95 Control Panel before creating a script, identify the data source name (DSN).
Match the length of the string. Since the data from the browser is passed through the encoding to the server side, the ASP is not entirely the useful information of the user input through its built-in object Request.
So it is handled. A flag character (such as # or chr (7)) can be attached after the input string. This article takes another method to calculate the length of the effective information. Thus the required
String.
Create a script file system object Scripting.FileSystemObject, turn on the text stream to read.
Features:
Directly to the .htm document, the full-text search, saves many conversion processes. .htm files are used for web pages, two in one fell swoop.
Applying ASP, simply, easy to implement.
This example ASP code:
<% @ Language = "VBScript"%>
<%
MousePointer = 13
SetConn1 = Server.createObject ("AdoDb.Connection")
Conn1.open "DSN = CZNJ"
Setrcst1 = conn1.execute ("Select * fromPages_catalog")
SCH_STR = Request.form ("Text1")
Doubbytes = len (SCH_STR) / 2SCH_STR = Left (SCH_STR, DOUBBYTES)
Response.write " Find results h2>
strong>"
Dimresult
Result = false
Response.write "
Dowhilenotrcst1.eof
Tit = rcst1.fields ("file_title")
Fn = rcst1.fields ("file_name")
File_name = server.mappath ("/") & "/ njweb / private /" & fn
TO_FIND = TEXT_MATCH (file_name, sch_str)
IFTO_FINDTHEN
URL = "Private /" & FN
Response.write " ENDIF RCST1.MOVENEXT Result = Resultorto_Find loop Response.write " ul>" IFNOTRESULTTHEN Response.write "
Not found! I> h3>"
ENDIF
mousepointer = 0
%>
FunctionText_match (filename, search_string)
Dimretstring
DIMFIND_POS
Dimfso, a
DIMDONE
TEXT_MATCH = FALSE
SetFSO = Server.createObject ("scripting.filesystemObject")
Seta = fso.opentextfile (filename, 1, false "forreading -> 1
DONE = a.atendofstreamortext_match
Dowhilenotdone
Retstring = a.readline
Find_pos = INSTR (Retstring, Search_String)
Iffind_pos> 0thentext_match = true
DONE = a.atendofstreamortext_match loop
a.close
ENDFUNCTION
Script>
Body>
Html>