A general database display program, can adjust any library, any field, multiple keyword search, automatic paging

Source: Internet
Author: User
Tags error handling table name
.
Ayu often write some database-related programs, of course, can not be separated from the display of data in the library, to tell the truth, do such a program is really boring ah, so, Ayu want to write a function, a common database display function. Requirements are as follows:
1. Can display the specified field, of course, the field name and display text can be different.
2. Can query by multiple fields at the same time, support fuzzy and accurate two kinds of query method.
3. There are two kinds of display modes of horizontal and vertical arrangement fields.
4. can automatically pagination.
5. Can set how many records per page display. Well, that's the big one. According to this requirement, Ayu wrote the following function.
In fact, Ayu wrote two functions here. One is Tabdisp (), which displays the contents of a specified table. There is also an ER () a small error handling function.
This function has 5 parameters (really enough). And each parameter must enter data, can not be blank, otherwise it will be wrong.
1 (TAB), the name of the table to invoke.
2 (Dispfild), to show which fields in the table, use < to separate the field names from the characters you want to display. For example, a field named: IMG, but to be displayed on the page as: Picture, then, write as img< picture, if there are more than one field, each field between the "," separated, alas, Old Voice.
3 (Findfild), by which fields to query, the field name and the characters to be displayed are separated by <.
4 (Pagen), how many records are displayed per page.
5 (FH), the direction of the display. Displays vertically when s. Horizontal display for H.
The return value of the function, when there is no error, the return value is true, otherwise it is false.
This function does not include a connection to the database. So you have to connect to the library yourself. In addition, in order to repeat the application. You can save this function specifically with a file, and then include the file when you need it.
Look at the following function: (Don't forget to read, finally I have an application example)
<%
' The following defines a function tabdisp (), Parameter tab, displayed table name, Dispfild, field to display, Findfild, query field, Pagen, display number per page, FH, show direction
' If the display succeeds, the return value is true, unsuccessful, and the return value is false.
' Multiple fields, separating
' Query fields must be included in the Display field.
' If the field name is not the same as the name to be displayed, use < delimited, preceded by the field name, followed by the displayed name, and the field to be searched must be < delimited to field name and display character
' FH display direction is ' H ' for horizontal display, for ' S ' when vertical display is case sensitive
FUNCTION Tabdisp (TAB,DISPFILD,FINDFILD,PAGEN,FH)
On Error Resume Next
IF dispfild= "" THEN dispfild= "*"
IF pagen= "" THEN pagen=15

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.