How to Use Wildcards In IDC Files (147361)



The information in this article applies to:

  • Microsoft Internet Information Server 1.0

This article was previously published under Q147361
We strongly recommend that all users upgrade to Microsoft Internet Information Services (IIS) version 6.0 running on Microsoft Windows Server 2003. IIS 6.0 significantly increases Web infrastructure security. For more information about IIS security-related topics, visit the following Microsoft Web site:

SUMMARY

When you use the Internet Database Connector (IDC) to query data from an ODBC database, you may need to use wild-cards in your SQL statements in the IDC file. The ODBC wildcard character is the percent (%) sign. After you set up an HTML query form, make sure that the percent (%) sign is entered in the query data.

WORKAROUND

If you do not want to instruct users to add the wildcard character to their queries, you can add the wildcard to the query data in the IDC file. In an IDC file, the single percent (%) sign is used to delimit the variables that are passed to it from the HTML form. Therefore, use two percent signs (%%) to insert the wild-card.

For example, given a form defined like this:
   <FORM METHOD="POST" ACTION="/scripts/getprod.idc">
      <P>Enter Name of product: <INPUT NAME="prdname">
      <P><INPUT TYPE="SUBMIT" VALUE="Run Query">
   </FORM>
				

In the Internet Database Connector file, GETPROD.IDC, you can append a wild- card to the user's input with the following sytax:
   SQLStatement:
   + SELECT * from products
   + where prod_name like '%prdname%%%'
				

If the user types in the word "paper" as input to the form, the resulting query (after translation of the variables) is:
   SELECT * from products where prod_name like 'paper%'
				

This selects any row from the database where the product name starts with the word "paper," followed by other characters.

Modification Type:MinorLast Reviewed:6/23/2005
Keywords:kbnetwork KB147361