首页 | 免费域名 | 个人服务器 | 一流信息监控拦截系统 | 虚拟主机知识库 | ASP 空间 | ASP技术大全 | 下载中心 | 客户服务中心
  7i24 > ASP技术大全 > 代码乐园 >
    7i24 .Com  
  用global.asa来实现在特定条件执行特定的ASP程序

7i24.Com不停为您服务


global.asa例子一

<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart
Application("SessionCount") = 0
End Sub

Sub Session_OnStart

Application.Lock
Application("SessionCount") = Application("SessionCount") + 1
Application.Unlock

If Application("SessionCount") > 100 Then

Application.Lock
Application("SessionCount") = 0
Application.Unlock

' Here you would put any code you need to run
' do not surround the code with <% %> tags
' For example you might run a database query that checks for expired accounts
End if

End Sub

</SCRIPT>

global.asa例子二

<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart
Application("SessionCount") = 0
End Sub

Sub Session_OnStart

Application.Lock
Application("SessionCount") = Application("SessionCount") + 1
Application.Unlock

If Application("SessionCount") > 15 Then

Application.Lock
Application("SessionCount") = 0
Application.Unlock

Set ObjMyFile = CreateObject("Scripting.FileSystemObject")
Set OpenMyFile = ObjMyFile.OpenTextFile(Server.MapPath("last-update.txt"))MyFileValue = OpenMyFile.ReadLine
OpenMyFile.Close
  
  If DateDiff("h",MyFileValue,NOW) > 6 Then

     ' Here you would put any code you need to run
     ' do not surround the code with <% %> tags
     ' For example you might run a database query that checks for expired accounts
      
      Set WriteMyFile = ObjMyFile.CreateTextFile(Server.MapPath("last-update.txt"))
      WriteMyFile.WriteLine(NOW)
      WriteMyFile.Close
  
  End if
End If

End Sub

</SCRIPT>



  2002年1月14日  阅读 1657 次  发送此页给朋友  来源:    版权争议  删除

相关文章:   近期热点:

上一篇: 用SysOjects获得数据库信息
下一篇: 设定你的ASP程序的执行次数
返回上一层...
搜索:

(C)2004-2022 7i24.Com 保留所有权利