Selection and filtering of database records in ASP applications

Source: Internet
Author: User
Tags require
I. Description
Most end users require their Web solutions to provide certain Report capabilities. With HTML and ASP, you can easily list records in tables and browse them one by one. However, users often require the ability to select a type of records from the drop-down list box (or other selection methods), or they want to use a "query interface" to create and execute queries, instead of using SQL directly. This article demonstrates how to use ASP technology to create an optional record filtering interface. Although the solution discussed here is quite simple, similar technologies can be used to provide complex query capabilities on any Web page.
Before coding any solution, you should fully understand and record the requirements of end users. In this example, you must be able to obtain a group of records of a specified table using the method of specifying the category name. You can select either all categories or a specific category. To implement this function, we use a "recursive" ASP page. The selection form provided by it contains a list of categories from the database, extract the result record set based on the data sent by the form. The result record is displayed in the form of a table for you to view.
2. Construct filter conditions
For such database applications, you should first understand the database table structure involved and the connection parameters required to connect to the database system. The method for specifying connection parameters is described in detail in Microsoft's ASP online document. In this example, two tables are used: Document_Category, which contains the unique category name Category_Name; Documents for the user to choose from. It contains other data corresponding to the category name, fields include Category_Name, File_Name, Comments, and Date_Submitted.
Select the category list in the form from the Category_Name field of the category table Document_Category. The code for constructing the category drop-down list box is as follows. Note that the VBScript ADO inclusion file is used here:
<! -- # Include file = "ADOVBS. INC" -->
<%
ConnString = "DSN = LocalUpload ;"
Set conn = Server. CreateObject ("ADODB. Connection ")
Conn. Open ConnString, adOpenForwardOnly
Set rs = SERVER. CreateObject ("ADODB. Recordset ")
'First retrieve the category record used to fill the drop-down list box
'Set SQL statements
StrSQL = "SELECT * FROM Document_Category order by category_name"

Rs. Open strSQL, conn, adOpenStatic
%>

<FORM name = "formCategory">

<Select name = "qryCategory"
OnChange = "getFilter (this. form. qryCategory)">
<OPTION selected> select a category:
<% Do While Not rs. EOF
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.