If the search page submits more than one search parameter to the server, you must write a SQL query and use the search parameters in SQL variables.
The connection should be to a database containing data you want the user to search.
Make sure the statement includes a WHERE clause with question mark (?) placeholders for the search parameters. The following example contains two placeholders:
SELECT EMPLOYEEID, FIRSTNAME, LASTNAME, DEPARTMENT, EXTENSION FROM EMPLOYEE WHERE LASTNAME LIKE ? AND DEPARTMENT LIKE ?
The parameters must be listed in the same order they appear in the SQL statement.
In the Name box, enter any valid parameter name. The name cannot contain any spaces or special characters.
In the Type pop‑up menu, select a data type. For example, if the parameter will hold text, select WChar.
In the Value box, enter the server variable that will contain the parameter value. For example, if the name of the form control on the search page is txtCity, a server variable called Request.Form(“txtCity”) will be created and a value is stored in it.
You can also enter a more complete expression that specifies a default value in case the server variable doesn’t exist. For example, if searching a Microsoft Access database, you can use % as a default value. The following expression checks to see if the server variable Request.Form("txtCity") exists. If the variable exists (that is, if it’s not equal to nothing), the expression returns the variable’s value; if it doesn’t exist, the expression returns the default value of %.
(IIf((Request.Form("txtCity") <> Nothing), Request.Form("txtCity"), "")) + "%"
For more information, see a Visual Basic or C# language reference.
The default values simulate the values that would otherwise have been returned from the search page. Click OK to close the test DataSet.
The SQL query is inserted in your page.
The next step is to display the search results in a DataGrid.