Database domain _asp class class for ASP classes

Source: Internet
Author: User
Grandma's, ASP class is really not studious ah, looking at the simple, can really use the time, the online code is all the error!!
Depressed Enju!! 3 days, finally debugging out, a simple database class model, do not dare to enjoy, take out to share it!
This work belongs to the Webmaster China www.zzcn.net Pumbaa All, you copy the time not to remove the copyright, otherwise the copy of the Family death ray!!!! Oh.. :)
Copy Code code as follows:

<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<%
' Pumbaa made a news class please consultation fee "webmaster China" http://www.zzcn.net qq:76526211
Class Newsclass
Private Zzcn,conn,cnnstr
Private title_p,id_p
' Object initialization
Private Sub Class_Initialize ()
' Response.Write ' Initialization <br>
Call Newsconnstart ()
End Sub

' destructor, automatically executes when the object is disposed with set nothing
Private Sub Class_Terminate ()

' Response. Write "Release object event:class_terminate<br>"
Call Newsconnend ()
End Sub

' Database link function
Private Sub Newsconnstart ()

Set conn = Server.CreateObject ("ADODB. Connection ")
Cnnstr= "Driver={microsoft Access DRIVER (*.mdb)}; "
Cnnstr=cnnstr & "dbq=" & Server.MapPath ("Admin/watavase/%29to-dream.mdb")
Conn. Open Cnnstr
' Response.Write Cnnstr & <br> '
End Sub

Private Sub Newsconnend ()
Conn.close
Set conn = Nothing
End Sub



'=========================================
' Function name Getrs ()
' Get a Recordset for a section
' Column name Lanmu
' A few records per page K
' Pages page
' The first few records n
' Date Riqi 1 to reverse order by date 0 for ascending
'=========================================
Public Function getrs (ByVal lanmu,byval k,byval page,byval n,byval)

sql = "SELECT * from articleclass where ClassName = ' &lanmu&" ' ORDER by ClassID Desc "
' Response.Write sql& ' <br> '
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open SQL, Conn, 1, 1

If not rs.eof then
Classid_p = RS ("ClassID")
End If

Rs.close
Set rs = Nothing




If Riqi = 1 Then
Riqi_p = "ORDER by UpdateTime Desc"
Else
riqi_p = ""
End If


sql = "SELECT * from Article where ClassID =" &ClassID_p& "&riqi_p
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open SQL, Conn, 1, 1
Rs. PageSize = k

If not rs.eof then
Rs. AbsolutePage = page
End If
i = 0
Do, not rs.eof and I < n
i = i + 1
Rs.movenext
Loop


' Response.Write ' rs<br> '
If n = I Then
Title_p = RS ("Title")
Id_p = RS ("ArticleID")
' Response.Write title_p
' Response.Write id_p
Else
Title_p = null
Id_p = null
End If


Rs.close
Set rs = Nothing
End Function



'----------------------------------------
'
' Attribute write title
Public Property Let title (ByVal v)
Title_p = V
End Property
' Property Read title
Public Property Get Title ()
title = Title_p
End Property

' attribute write title ID
Public Property Let ID (ByVal v)
Id_p = V
End Property
' Attribute read header ID
Public Property Get ID ()
id = id_p
End Property

End Class




%>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>asp Database class Pumbaa making qq:76526211</title>

<body>

<%
Dim News
Set news = new Newsclass
Call News.getrs ("site collection", 1,1,1,1)
Response.Write News.id & "" & News.title
Set news = Nothing
%>
</body>



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.