缓存类及打开数据库连接函数
懒人的作品,我连长一点点的代码,都写成函数了。。。用起来,可以偷懒,哈哈。。。
<%'@ LANGUAGE = VBScript CodePage = 936
Dim jz
Set jz=New jz_clsmain
jz.Cache_count=0
jz.web_name="华人中小企业资源网"
Class jz_clsmain
Public rs,conn,sql,db
Public web_name,t,t_s,t_h,cache
public i_0,i_1
public Reloadtime,CacheName,LocalCacheName,Cache_Data,Cache_count
Private Sub Class_Initialize()
ReDim db(4),conn(4),rs(4),sql(4)
ReDim t(20,4),t_s(20,3)
Reloadtime=14400*60
'CacheNameCacheName=Replace(Replace(Replace(Server.MapPath("/"),"/",""),":",""),"","")
CacheName=request.servervariables("url")
CacheName=left(CacheName,instrRev(CacheName,"/"))&"jz"
Cache_count=1000
web_name="匠族"
end sub
Private Sub class_terminate()
i_1=LBound(db)
for i_0=0 to i_1
On Error Resume Next
'Response.Write(i_0&"<br/><br/>")
if isobject(rs(i_0)) then rs(i_0).close:set rs(i_0)=nothing
If IsObject(Conn(i_0)) Then Conn(i_0).Close:Set Conn(i_0) = Nothing
next
End Sub
Public Function tree_00(str_0)
dim i,Jz_temp(1)
for i=0 to str_0
Jz_temp(0)=Jz_temp(0)&Jz_temp(1)
Jz_temp(1)="../"
next
tree_00=Jz_temp(0)
end Function
public function conn_00(str_0,str_1)
str_1=tree_00(str_1)
db(str_0)="Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(str_1&"data/data_"&str_0&".mdb")
'Response.Write(db(str_0))
end function
'str0=0-4<定义选择的DB(str0),并定义conn(str0)及rs(str0)>;str1=true,false<是否创建数据库连接>;str2=true,false<是否创建rs对象>;
Public Function c_r_s(str0,str1,str2)
On Error Resume Next
if str1 then
Set Conn(str0) = Server.CreateObject("ADODB.Connection")
补充:asp教程,技巧与性能优化