Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

MS SQL

Posted Nov 14, 2001

Using index server with ADO calls - Page 3

By DatabaseJournal.com Staff

Creating the ASP Page

The ASP Page is where things get really cool. You use the values from the form to drive the objects that will query the index server.

Here's the overall process:

  1. Set up the server object
  2. Open the recordset
  3. Step through the recordset, using standard ADO methods

You can download the basics of the ASP page by clicking here and then follow along. Again, it's a text file from this link, but you can cut and paste it as needed for your use.

The first thing you have to do is to set up the reference to the index server object. You do that by using the server.creatobject method:

Set objQuery = Server.CreateObject("ixsso.Query")

Add in the properties...

Now the objQuery object is set up and ready to be configured, prior to setting up the recordset that references it.   Of course one of the fundamental things that you'll need to do is to set up the query - what you are looking for in the database.  This is done from the incoming URL information - and there is a method to pull all of this from the URL and put it into the object automatically:

objQuery.SetQueryFromURL(Request.QueryString)

This will pull all of the different parameters, properties and query string information from the URL and put it where it belongs in the object.  This is how the parameters set up as hidden fields in the form are translated into properties for the search. 

Stir in the columns...

Next, indicate which columns you'll want to return from the search. We've called out the most common, and those which will provide you with summary and URL information. There are others, but that's a subject for a future article!

objquery.columns="filename,HitCount,vpath,DocTitle,characterization"

In this case, we're asking for the filename, the number of hits that are occuring in the source file for the search string we've provided, the document title (between the TITLE tags in the HTML), and the summary information for the file. This will give the user the overview of what the page is about.

If you place the DESCRIPTION meta tag in your pages, the characterization will include that information. If not, the characterization will provide a look at the first portion of each page as it's shown. Index server will ignore include and scripting text in the files, so you'll generally only get "real" content.

And Bake...

You're ready to query the database - simply create the recordset just as you would any ADO data source.

set rsQuery = objquery.createrecordset ("nonsequential")

Voila!  You've just queried your server.  No mess, no fuss.  What you have now is a recordset, rsQuery, that you can use MoveNext, MovePrev, etc. methods on.  You'll be able to reference each of the columns returned by the query by simply calling them out with the rsQuery object:

rsquery("doctitle")

You even have the standard recordcount property associated with the results.  rsquery.recordcount will let you know the total number of rows returned, up to the maximum value you indicated in the properties for the query. 

Give it a try - just search from the tool on the left - and you can follow along in the code from the pages you've just downloaded. It's really an excellent way to search your site and use the Index Server.

The Frosting...

The frosting on this cake is how you handle the output of the search results. Paging, formating the links, etc. It's all presentation, right?! Stay tuned - if enough people are interested in hearing more, I'll write up part II of this article - How to page your results, how to format your results.



MS SQL Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM