My first ASP class (show the last article)

Source: Internet
Author: User

Object-oriented is the trend of today's programming languages. However, ASP's support for Object-Oriented is quite chilling. Now I feel that ASP classes are just a bunch of functions.

However, I didn't learn object-oriented languages at school, and my understanding of object-oriented is still starting with ASP.

Write down the first ASP class I wrote, and remember the right

If ASP is available for beginners, you can also make a reference.

1 <%
2 class show_p_n
3 '************************************** **************************************** *****************
4. display the next class of News (articles)
5 'actually, it's just a matter of fact, just a trainer. I learned how to write a class.
6' the input data type has not been detected. If an input error occurs, an error will occur (it seems that error handling and fault tolerance should be added)
7' ^ return ^
8' 2004-10-29
9 '************************************** **************************************** *****************
10 '********************* The following is an example of an application, which is very simple, I will not say much about it **********************************
11' ********** dim zyt
12 '********** set zyt = new show_p_n' create an object instance
13 '********** zyt. getconn = conn' enter the connection object conn of the database.
14 '********** zyt. presentid = new_id' enter the ID of the current news (Article)
15 '*********** zyt. tablename = "apec_news"' name of the table where news (articles) is located
16 '********** zyt. fieldname = "new_id"' uniquely identifies the field name of a news article
17 '*********** zyt. getrs' to get the result
18 '*********** response. write ("the title of the previous article:" & zyt. rsprev ("new_title") & "<br>") 'output the title of the previous Article
19 '*********** response. write ("next article title:" & zyt. rsnext ("new_title") & "<br>") 'output the next title
20 '********** set zyt = nothing' destroy the object instance
21 '************************************** **************************************** *****************
22 private zytpresentid 'current article (News) ID
23 private zk_conn 'connection to the database Conn
24 private tablen' name of the table to be queried
25 private fieldn 'field name that uniquely identifies a news (Article)
26
27 private sqlprev: query the next SQL statement
28 private sqlnext 'query the previous SQL statement
29
30 public rsprev: displays the RS of the previous Article
31 public rsnext: displays the next rs
32 ':::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::: :::
33 private sub class_initialize () 'class initialization event
34 end sub
35
36 private sub class_terminate () 'class end event
37 rsprev. Close
38 set rsprev = nothing
39 rsnext. Close
40 set rsnext = nothing
41 end sub
42 ':::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::: :::
43 :::::::: ::::::::::::::::::::::::::::::::
44 public property let getconn (obj_conn) 'connect to the database's conn
45 set zk_conn = obj_conn
46 end property
47
48 public property let presentid (byval vpid) 'current article (News) ID, numeric type
49 zytpresentid = vpid
50 end property
51
52 public property let tablename (byval vtablename) 'name of the table to be queried
53 tablen = vtablename
54 end property
55
56 public property let fieldname (byval vfieldname) 'field name that uniquely identifies a news (Article)
57 fieldn = vfieldname
58 end property
59 '************************************** **************************************** *************************
60 public sub getrs ()'
61 sqlprev = "select top 1 * from" & tablen & "where" & fieldn & "<" & zytpresentid & "order by" & fieldn & "DESC"
62 sqlnext = "select top 1 * from" & tablen & "where" & fieldn & ">" & zytpresentid & "order by" & fieldn
63 set rsprev1_zk_conn.exe cute (sqlprev)
64 set rsnext=zk_conn.exe cute (sqlnext)
65 end sub
66 '************************************** **************************************** *************************
67 end class
68%>

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.