FP2000: How to Search Using LIKE In SQL Statement For ASP

ID: Q205231


The information in this article applies to:
  • Microsoft FrontPage 2000


SUMMARY

This article describes how to search a database using the LIKE parameter in a Structured Query Language (SQL) statement in the Database Results Wizard of FrontPage.

This article assumes that you have a basic knowledge of how to query a database using Active Server Pages (ASP) technologies in FrontPage.


MORE INFORMATION

When used in a search, the LIKE parameter generates a result set based on a minimum amount of information typed into the form field of a HyperText Markup Language (HTML) form. For example, if you type mic in the form field, the results may include Microsoft, microphone, microwave, and so forth.

Method 1: Use the Wizard to Specify What You Want to Compare

  1. In Page View of FrontPage, open the page to which you want to add the data region.


  2. On the Insert menu, point to Database, and click Results


  3. In Step One, choose your Data Source, and click Next.


  4. In Step Two, click to select Record Source and select the table you want to retrieve data from. Click Next.


  5. In Step Three, edit the list of fields that will be included in your query.


  6. Click More Options.


  7. Click Criteria.


  8. Click Add.


  9. In the Add Criteria dialog box, select the field name you want to compare, for example, "productname".


  10. Click the Comparison list, and select "Like" or "Is not Like".


  11. In the Value box, specify the value (this is the form field name you will use to search with), and click OK twice.


  12. Click Next twice.


  13. NOTE: If you want FrontPage to create a form using this statement, click Add Search Form on step 5 of the database results wizard.

Method 2: Use Custom SQL Code

To use the LIKE parameter in an SQL statement in FrontPage, start the Database Results Wizard and follow these steps:
  1. In Step one of the Database Results Wizard, select the database you want to use, and click Next.


  2. Click Custom Query, and Click Edit


  3. Use the following syntax in the SQL statement:
    
    SELECT * FROM <Table Name> WHERE (<Database Field> LIKE '%<HTML
       Field>%') 
    where <Table Name> is the name of a table in the database, <Database Field> is a field in that table, and <HTML Field> is the name of an HTML form field on an HTML document (usually a text box).


The extra percentage signs around the HTML form field name act as wild cards so that the LIKE string can match multiple records. For example, if you entered this SQL code

SELECT * FROM Employees WHERE (City Like '%City%') 
And type London in the form field, all records that contain London in the city field are returned.

NOTE: This example works with the Northwind sample database file that can be specified in Step one of the Database Results Wizard.

NOTE: If you use this query and the form field is blank, when you submit the form, all records in the database will be returned. However, you can require that a value be entered before the form is submitted by using form field validation.

Additional query words: 98 SQL ASP IDC Database LIKE front page

Keywords : kbdta fpscript
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbinfo


Last Reviewed: December 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.