Microsoft KB Archive/292624

{|
 * width="100%"|

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

 * }

Q292624

-

The information in this article applies to:


 * Microsoft FrontPage 2002

-

For a Microsoft FrontPage 2000 version of this article, see Q205231.

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 Microsoft FrontPage.

This article assumes that you have a basic knowledge of how to query a database using Active Server Page (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 &quot;Microsoft&quot;, &quot;microphone&quot;, &quot;microwave&quot;, and so forth.

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

 * 1) Open a Web on an Internet Information Server (IIS) Web server and create a new blank page.
 * 2) On the Insert menu, point to Database, and then click Results.
 * 3) In Step 1, choose your Data Source, and then click Next. (For example, choose to use the Northwind sample connection.)
 * 4) In Step 2, click to select Record Source, select the table from which you want to retrieve data, and then click Next. (For example, select the &quot;Employees&quot; table.)
 * 5) In Step 3, edit the list of fields that you want to 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, choose &quot;City&quot;.)
 * 10) Click the Comparison list, and select &quot;Like&quot; or &quot;Not Like&quot;.
 * 11) In the Value box, specify the form field name you will use to search with, and then click OK three times.
 * 12) Click Next twice.
 * 13) In Step 5, if you want FrontPage to create a form using this statement, click to select the Add Search Form check box.
 * 14) Click Finish.

Method 2: Use Custom SQL Code
To use the LIKE parameter in an SQL statement in FrontPage, start the Database Results Wizard and then follow these steps:

 Open a Web on an IIS Web server and create a new blank page. On the Insert menu, point to Database, and then click Results. In Step 1, choose your Data Source, and then click Next. (For example, choose to use the Northwind sample connection.) Select Custom Query, and then click Edit.  Create your query by using syntax similar to the following SQL statements:   Query from a Form Field: SELECT * FROM  WHERE ( LIKE '%::::%') Where <Table Name> is the name of a table in the database, <Field Name> is a field in that table, and <Form Field> is the name of an HTML form field on an HTML document (usually a text box). </li>  Query a Specific Value: <pre class="CODESAMP">SELECT * FROM <Table Name> WHERE (<Field Name> LIKE '%<Unique Text>%') Where <Table Name> is the name of a table in the database, <Field Name> is a field in that table, and <Unique Text> is the text that you are querying. </li></ul>

The extra percentage signs around the form field name or query text act as wildcards so that the LIKE string can match multiple records. For example, if you entered this SQL code: <pre class="CODESAMP">SELECT * FROM Employees WHERE (City Like '%LON%') Any records that contained London in the city field would be returned. </li> Click Next three times.</li> In Step 5, if you want FrontPage to create a form using this statement, click to select the Add Search Form check box.</li> Click Finish.</li></ol>

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: SQL ASP IDC Database LIKE front page inf

Keywords : kbdta

Issue type : kbhowto

Technology : kbFrontPageSearch kbFrontPage2002 kbFrontPage2002Search