![]() |
|||||||||||
|
|
|
|
|
|
|
||||||
![]() ![]() |
|
|
OR like this:
|
The extension will rewrite the recordset on your page to use the new dynamic SQL string.
The pre-requisites to use this extension are as follows:
With that in place, you can use the Dynamic Search SQL server behavior.
The steps to apply the server behavior for a basic search page with one search field are as follows:
Server Behaviors >> DW Team >> Search >> Dynamic Search SQL
That brings up the following dialog box:

After clicking OK you should be able to save the page and browse it. Test it with different types of search strings.
If you are using a form with radio buttons or a list box to allow for other search options (any word, all words, or exact phrase) you can use the advanced tab. To add some advanced features to the page, follow the 5 steps above, and then click the advanced tab.

"SELECT * from mytable WHERE accesslevel = 'web'"
If you didn't use the checkbox option, your where clause would be stripped from the SQL statement to resemble the following:
"SELECT * from mytable " + tfm_SQLstr + ""
By using the checkbox option, you can keep both parts of the where clause:
"SELECT * from mytable " + tfm_SQLstr + "AND accesslevel = 'web'"
ALSO INCLUDED is a server behavior that highlights the search words in a database result field. You can apply the server behavior to the field that is the result. The dialog box looks like this:

You simply choose the recordset name, the field that you want to utilize it on, the name of the search field, and any tags or code that you want to insert before and after the match. Typically you would use a <strong></strong> tag around your search result. A search on a job description field of the words asp, sql, vb might return a result that looked like this:
| JobLocation | JobDescription |
|---|---|
| San Francisco, CA | This position requires a minimum 3 to 5 years of working experience with key skills in Java, JavaScript, ASP, VBScript, HTML. Candidate must posses a detailed knowledge of web site concepts, web browser protocols in the design and display of web pages |
| Buffalo, NY | Must be proficient in all aspects of database programming using SQL Server. Must have extensive knowledge in building dynamic data-driven web sites using Flash 5.0, Generator 2.0, SQL Server, Javascript and ASP |
You can see that the replacement is versitile in that it maintains the CASE of the words that are searched on and also allows MULTIPLE word matches.
One last server behavior in the package is named Debug SQL String. It allows you to display the dynamic where clause that is created. Simply drop it into the page and you can display the where clause string that is created by the server behaivors. The SQL statement that produced the above results would have looked like this:
SELECT JobLocation, JobDescription FROM mytable
WHERE
((JobLocation LIKE '%asp%') OR (JobDescription LIKE '%asp%'))
AND
((JobLocation LIKE '%vb%') OR (JobDescription LIKE '%vb%'))
AND
((JobLocation LIKE '%sql%') OR (JobDescription LIKE '%sql%'))
The text that is in bold is generated by the Dynamic Search SQL server behavior and would appear on your page as you are debugging your search query. If you chose the "Any words" option, the dynamic SQL would look like this:
SELECT JobLocation, JobDescription FROM mytable
WHERE
((JobLocation LIKE '%asp%') OR (JobDescription LIKE '%asp%'))
OR
((JobLocation LIKE '%vb%') OR (JobDescription LIKE '%vb%'))
OR
((JobLocation LIKE '%sql%') OR (JobDescription LIKE '%sql%'))
This is a fairly simple statement, but you can imagine what would happen if the user entered 6 or 7 words in the query and you are searching across 3 or 4 columns. The server behavior will take care of these situations as well.
There is an FAQ page here.
NOTE: If you are using the Simple recordset, the recordset will not be editable in the Simple recordset dialog box any more -- always edit your recordset from the Advanced dialog box to avoid any problems.
NOTE: The server behavior works by using dynamic SQL. Therefore, it won't work with a stored procedure. It works well with standard recordsets created using tables or views.
Dynamic Search Suite for ASP/VBScriptBuy Now! |
| The extension author Tom Muck was nominated by Macromedia in 2000 in the Best Extension Developer category. |
|