Sunday, November 19, 2006

WAD

Dreamweaver TechNote

Search/results page set always returns the same record

Issue

A search/results page set may fail for a number of reasons. Assuming you are not experiencing database connectivity or HTTP errors, the most common problem with a search/results page set is that the same record is returned, regardless of the search parameter. The record(s) returned is usually either the first record in the recordset or the default record(s) specified for the recordset.

Reason

Following are the typical points of failure in a search/results page set:

  • The search parameter is not passing correctly from the search page.
  • The results page is not catching the search parameter correctly.

Solution

Since this issue may have several causes, there is no one solution. Rather, using the following troubleshooting tips may help you isolate the root cause.

Search page:

  • Set the form method to GET in the Property inspector.
  • On the search page, be sure the form objects in the form are named in the Property inspector. Form objects include text fields, list/menus, radio buttons, etc.

Please refer to Building a simple database search feature or the"Building Search/Results Pages" section of the Using Dreamweaver help system (Help > Using Dreamweaver) if you need assistance with setting the form method or naming form objects.

The GET method is more helpful than the POST method when developing or troubleshooting a search/results page set, because you can see the search parameters appended to the results page's URL as a query string. After clicking the submit button on a search page using the GET method, the URL in the web browser will look something like this:

http://www.mysite.com/results.asp?txtMyField=20

In this example, the visitor to the web page typed "20" in the text field labeled "txtMyField" on the preceding search page.

Results page:

  • Simple view of the Recordset dialog box
    You can use the simple view of the Recordset dialog box if your search only has one parameter. When using the GET method for the search page form, you need to set up the recordset on the results page so that the Filter uses a URL parameter. Please refer to Building a simple database search feature or the "Building Search/Results Pages" section of the Using Dreamweaver help system (Help > Using Dreamweaver) if you need assistance with setting up the recordset in the simple view.

    Here is a clarification of what the Filter settings refer to:

    The filter settings use the database field name, the URL parameter, and the form field name from the previous page.
  • Advanced view of the Recordset dialog box
    You need to use the advanced view of the Recordset dialog box if your search has more than one parameter. You need no special settings in the advanced view when using the GET or POST method on the search page. If you are using the GET method in ASP, you could specify Request.QueryString("txtMyField") for the variable's Run-Time Value, however Request("txtMyField") is a shortcut that will also work. The shortcut method will search both the ASP Form collection and the ASP QueryString collection for the element labeled"txtMyField". Just be sure not to use Request.Form("txtMyField") when using the GET method. Please refer to Building a multiple-parameter search feature or the "Building the results page" section of the Using Dreamweaver help system (Help > Using Dreamweaver) if you need assistance with setting up the recordset in the advanced view.

    Here is a clarification of what the Variable settings refer to:

    The Name setting is arbitrary, but the Default Value and Run-Time Values allow you to specify which recordset field and record number should be the default.

Once the recordset has been set up, test it with different default values in the Recordset dialog box, to make sure the filter is returning the correct records.

Once your search/results page set is working in the web browser using the GET method, you can go back and change the form to the POST method if you prefer not to see the search parameters being passed in the URL. If you are using the POST method and the simple view of the Recordset dialog box, you would use "Form Variable" instead of "URL Parameter" in the Filter settings. If you are using the advanced view of the Recordset dialog box, you can leave the recordset settings as they are, unless you are using ASP and you specified Request.QueryString. In that case, you will need to change "Request.QueryString" to either "Request" or"Request.Form".

Other troubleshooting tips:

  • As with all page sets created with Dreamweaver, be sure to save all pages and upload them to the remote server or testing server, if you are using one. A useful development method is to hard code some text in the body of the page so you know you are viewing the latest version of your page (e.g. "9:08 am"). Browser caching, multiple copies of the page on your machine, and forgetting to upload the latest version of your page, can all cause confusion.
  • Make sure that you can view a simple, unfiltered recordset in the web browser.
  • If you have multiple search parameters, start with one and increase the parameters after testing.
  • Try making a "bare bones" test search/results page set from scratch (File > New File), and see if you can get the basic search functionality working. Keep the pages as simple as possible (no templates, behaviors, server behaviors, images, formatting, custom code, library items, etc.).

Additional information

The Dreamweaver help system (Help > Using Dreamweaver) described how to make both simple and multi-parameter searches for each application language.

Following are additional articles and TechNotes related to search/results page sets:

Last updated: March 12, 2004
Easy Link this TechNote

http://www.adobe.com/go/tn_19204

Easy Links give you a simpler URL to reference in emails, as bookmarks… anywhere.

No comments: