注册 登录
编程论坛 ASP技术论坛

如何定时删除数据库中的记录

michaelbyron 发布于 2008-01-24 17:29, 2673 次点击
如何定时删除数据库中的记录?
我在每天00:00:00自动删除注册15未通过审核的ID
该怎么写?
6 回复
#2
yms1232008-01-24 17:43
这个除非在服务器上运行某个exe程序来实现,或者在数据库里些存储过程实现。ASP的网页是被动执行的请求响应模式,定时执行是个问题。
#3
Kettyjin19832008-01-25 08:46
我以前也碰上这个问题,我们公司有K2平台,后来就用k2里的功能实现了.
#4
icecool2008-01-25 19:35
在服务器上建一个批处理命令,用计划任务让期在00:00:00执行,批处理打进开进行删除的一特定页面
#5
michaelbyron2008-01-30 15:44
回复 4# 的帖子
问题服务器它不是咱家的
就没有别的办法了吗?
比如JAVA之类的
我看挂QQ程序应该有这种功能才是
#6
yms1232008-01-30 16:08
的话没准可以,ASP不好做。
#7
icecool2008-03-10 18:55
刚回看贴子,看到此贴时,突然想在统计在线人数的问题。
便想可不可用同样方式global.asa来实现楼主的想法,
搜索了一下,还真找到了相关内容,如下,楼主自已看看能否做得成,
很久没写过,IIS也没装,你自已看着能不能实现了:
<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>
1