ONLINEPROOFINGSITE.COM

shared tools proofing tools - www.onlineproofingsite.com

Menu


Figure 27.10. The Value text box in the Parameter dialog is populated with a conditional expression. 9. Click OK to close


the Edit Parameter dialog. Notice that the parameter is added to the Parameters list in the DataSet dialog box. Of course, if you need to re-open the Edit Parameter dialog to make changes, simply click the Edit button. 10. Modify the SQL statement to accept a parameter. In ASP.NET, this is done by appending the LIKE keyword followed by the ? symbol to the WHERE clause as follows:   SELECT * FROM EmployeeStore WHERE ItemName LIKE ?   The result of the completely formatted DataSet dialog should resemble Figure 27.11. Figure 27.11. Format the SQL statement in the DataSet dialog to accept the parameter. [View full size image] 11. Click OK. The DataSet appears in the Bindings panel. 12. Assuming search_results.aspx is already open, go ahead and add all the dynamic text elements to the page, dragging the fields from the DataSet into their respective positions on the page. You might also want to add captions for the field names. Figure 27.12 shows the result of the dynamic text additions. Figure 27.12. Add the fields from the DataSet as dynamic text. [View full size image] Save your work and test the results in the browser. Figure 27.13 shows the search result when I type the value Dorknozzle Shirt and click Submit. Figure 27.13. Dorknozzle Shirt was searched for and the results came back with a match. [View full size image]   As you can see, the search produced a filtered result (1 record) based on the value I entered in the search text box. The results are made possible because of the parameter. The parameter captured the results of the request when the form was submitted. The parameter was then appended to the SQL statement, and the exact result based on the filtered criteria was returned. Working with Parameters in ColdFusion Similar to the ASP, ASP.NET, and PHP server models, search functionality for our Dorknozzle site can easily be created using the ColdFusion server model. The difference between ColdFusion and the other server models, however, lies in how we store and use the value that's coming across, appended to the URL in the address bar. As you saw in the previous two sections, variables and parameters were used for collecting, storing, and then subsequently reusing the value coming across. In the ColdFusion server model, however, variables and parameters are not necessary. Instead we can dynamically append to the WHERE clause of the SQL statement the value of the form name as a parameter, enclosed with # symbols. To demonstrate this, let's build the search functionality in ColdFusion by following these steps: 1. With the Recordset dialog box still open in Advanced mode, modify the SQL statement to accept the form object's name enclosed with # symbols in the WHERE clause as follows:   SELECT * FROM EmployeeStore WHERE ItemName LIKE '#txtSearch#'