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 ()
%>