Searching with multiple search parameters (ASP.NET)
If the search page submits more than one search parameter to the server, then you must write a
SQL query and use the search parameters in SQL variables.
Note: If you have only one search condition, you can use the simple DataSet dialog box to define your
DataSet (see
"Searching with only one search parameter (ASP.NET)" on page
To search for records in a database using SQL:
Open the results page in Dreamweaver, and then create a new DataSet by opening the Bindings
1
panel (Window > Bindings), clicking the Plus (+) button, and selecting DataSet from the pop-
up menu.
Make sure the advanced DataSet dialog box appears.
2
If the simple dialog box appears instead, switch to the advanced dialog box by clicking the
Advanced button.
Enter a name for the DataSet and select a connection.
3
The connection should be to a database containing data you want the user to search.
Enter a Select statement in the SQL text area.
4
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 ?
For help on SQL syntax, see
Give the placeholders the values of the search parameters by clicking the Plus (+) button in the
5
Parameters area and entering the parameter's name, type, and value.
The parameters must be listed in the same order they appear in the SQL statement.
In the Name text 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, then a server variable called
Request.Form("txtCity") will be created and a value 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")
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.
Appendix B, "SQL Primer," on page
exists. If the variable exists (that is, if it's not equal to nothing),
Building a database search page (ASP.NET)
682).
753.
683
Need help?
Do you have a question about the DREAMWEAVER MX 2004-USING DREAMWEAVER and is the answer not in the manual?
Questions and answers