Implementation of MVC Architecture ASP

Source: Internet
Author: User
D.asp
<%
Class DataAccess

Private P_dbname
Private P_conn
Private P_rs

Public Property Let dbname (O_dbname)
P_dbname=o_dbname
End Property

Public Property Get dbname
Dbname=p_dbname
End Property

Private Sub Class_Initialize
Set P_conn=server. CreateObject ("Adodb.connection")
Set P_rs=server. CreateObject ("Adodb.recordset")
End Sub

Private Sub Class_Terminate

End Sub

Public Sub Opendb ()
P_conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &server.mappath (p_dbname)
End Sub

Public Function GetRows (o_sql,o_recordnum,o_recordstart,o_recordfields)
P_rs.open o_sql,p_conn,1,1
P_rs.move O_recordstart
Getrows=p_rs.getrows (O_recordnum,0,o_recordfields)
P_rs.close
End Function

End Class
%>
M.asp
<%
Class Usermodel

Private P_da

Private Sub Class_Initialize
Set P_da=new dataaccess
P_da.dbname= "Ip.mdb"
P_DA.OPENDB ()
End Sub

Private Sub Class_Terminate
Set p_da=nothing
End Sub

Public Function Getusersrows ()
Getusersrows=p_da.getrows ("Select * from IP", -1,1,array ("Onip", "OFFIP"))
End Function

Public Function Getuserrow (user_id)
Getuserrow=p_da.getrows ("select * from IP where id=" &user_id,-1,0,array ("Onip", "OFFIP"))
End Function

End Class
%>
V.asp
<%
Class Userview

Private P_model
Private P_rows

Private Sub Class_Initialize
Set P_model=new Usermodel
End Sub

Private Sub Class_Terminate
Set p_model=nothing
End Sub

Public Sub Showusers ()
P_rows=p_model.getusersrows ()
For i=0 to UBound (p_rows,2)
Response.Write P_rows (0,i) & "" &p_rows (1,i) & "<br>"
Next
End Sub

Public Sub Showuser (user_id)
P_rows=p_model.getuserrow (USER_ID)
Response.Write P_rows (0,i) & "" &p_rows (1,i) & "<br>"
End Sub

End Class
%>
Index.asp
<!--#include file= "d.asp"-->
<!--#include file= "m.asp"-->
<!--#include file= "v.asp"-->
<%
Set User=new Userview
User.showusers ()
%>




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.