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)


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.