Application of ASP and ADO in Web database query

Source: Internet
Author: User
Tags html page web database
ado|web| Data | Database----* SPECIFIC implementation

----Query Home page for Hong Kong and Macao documents information inquiries, the corresponding procedures for gacx.as
P, the results of the query are displayed in two ways, one is to display the main information-Hong Kong
o Certificate Information Query results list, the corresponding procedure for gacxlb.asp, one is
Display all information-Hong Kong and Macao certificate information query results, the corresponding procedures for GACX
xq.asp, if the query condition is not satisfied, a prompt page is also displayed
, which tells the user that there is no result that satisfies the condition, which is gacxts.as by the program
P Complete.

----first based on the database provided by the customer and the requirements of the query
Query, query results, query results list page, but also to give a Jane
A single prompt interface that tells the user that there is no result that satisfies the condition, please
New query, which can be done with FrontPage 98, and the entire page should be
Do simple and generous, the theme is clear. Program code in Microsoft Visual Inter
Dev under the write.

----The following to process the contents of the encoded database ZD.DBF. From the image below, you can
See a lot of options such as "sex", "birthplace", and so on with the dropdown box, which
The contents of the options are extracted from the ZD.DBF database, which is exactly what
One of the highlights of this program's database processing process (this part is
Tao Zemin Engineer designed and implemented), because there are many options
, for example, there are 101 items in the exit port, although you can also use < select > <
Option >...</option ></select > format the various options in the HTML page
Enumerate, but that will cause a lot of trouble to the maintenance of the program, once the
The content of the code database has changed, the program will have to make a lot of changes,
And the options for the Drop-down box are encoded in ZD.DBF, to the main data
When you enter data in a library, these options are encoded only, but are displayed without
To display the code, the corresponding characters must be displayed. This part of the process
The order code is as follows (in the case of sex):

<%
Set conn=server.creatobject ("ADODB. Connection ")
Conn.Open "Gacx"
Set RS =conn.execute ("Select BC,
MC from ZD Where BC like "se%")
Response.Write "< SELECT size=1 name=" SEX ">"
Do but not RS. Eof
Response.Write "< option
Value= ' "RS (0)" ' > "&rs (1)
Rs.movenext
Loop
Response.Write "</select >"
Rs. Colse
Conn.colse
% >
----where ZD.DBF contains two fields the MC, BC,MC represents the item to be encoded, such as
Male, female, BC representation code, such as sex-coded top two for "se", Male with "se"
1 "said that the female uses" the Se2 "to express.

The most important thing in----database query is how to get the query criteria.
In this example, the items to be queried can be grouped into two categories: the type of text entered
, and the other is the item that is selected from the dropdown box, in the processing
Should be differentiated, the text type of query conditions are very good handling, such as last name
Name, I named "XM" to the input, if the input query item is not
Add a query condition "Name=request.form" ("XM") in empty time;
The Pull box is much more complex to handle, when the Drop-down box selects an item, such as a sex
Do not select male, the dropdown box is entered "SE1", (but reflected in the database
Is "Sex=1", because the entry in the dictionary with the encoded item in the database is only
Input encoding), is to query the "SEX=SE1" of the item, processing to be "SE1" in
"1" extracted, here only need to use a function mid can, query bar
The item is "SEX =mid (" SE1 ", 3, 1)", which is to find sex=1 items from the database and
List all the items that meet the conditions without repeating them.

----query results are very easy to display, only the query results of each
The record is displayed in the form of a list, note that the query knot is displayed
When you want to display the corresponding character of the encoding, it is to find the code in the dictionary
The encoded values for the items in SE & 1 are as follows:

< table border= "1" width= "95%"
Bordercolor= "#C0C0C0" cellspacing= "0" cellpadding= "0"
bordercolorlight= "#C0C0C0"
bordercolordark= "#C0C0C0" height= ">"
< tr >
< TD width= "9%" align= "center"
height= "1" >< p align= "center" >
Name </td >
< TD width= "12%" align= "center"
height= "1" > Archive No. </td >
< TD width= "6%" height= "1" >
< p align= "center" > Sex </td >
......
</tr >
<%i=1% >
<%while not RS. EOF% >
< tr >
< TD width= "9%" align= "center"
height= "1" ><%=rs ("name")% ></td >
< TD width= "12%" align= "center"
height= "1" ><%=rs ("Dang")% ></td >
< TD width= "6%" height= "1" ><%=func
("Se" & RS ("Sex"), gacx)% ></td >
......
</tr >
<%rs. movenext% >
<%i=i+1% >
<%wend% >
</table >
----of which, Func ("Se" & RS ("Sex"), GACX) is a function that implements data from the
Source to get the function of the character corresponding to the encoding.



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.