遇到一个asp与js的代码,需要隔1小时运行一次(附源码),请前辈指导一下思路!小弟先感谢了!

salecn 2010-08-12 06:03:49
各位前辈好,遇到一个asp与js的代码,需要隔1小时运行一次(附源码),请前辈指导一下思路!小弟先感谢了!

环境:asp+iis+sqlsever2000

目的:想实通过Google Map Api的计算经纬点距离函数,每隔1小时计算下数据库中两点的距离,结果存入数据库。
(程序是用asp做的,判读距离的函数是Google Map Api的javascript代码。)

问题: 怎样让下面的asp文件每隔1小时就自动运行呢?(改成vbs行不行啊)

源代码如下:


<%@Language="VBScript" CodePage="65001"%>
<%Session.CodePage="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>计算距离</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA-9XCdVovUm991Ek1s6cgdxQxeZ2O7p53-bIxOKwikWnaEuG9JxS3SIpC7vSxeCQoW3L41AQrqZ-HdA &sensor=true_or_false" type="text/javascript"></script>
<!--#include file="../../../conn/conn.asp"-->


</script>
<%
set table=server.CreateObject("mzz.biao")
bianhao=request("bianhao")
name=request("name")

%>

<%
If Request.QueryString("name") = "" Then

'开始读取数据库中的经纬点
sql="select 当前地点,终点地点 from 业务订单 where 订单编号='"&bianhao&"'"
set startrs=conn.execute(sql)
startsql="select lon,lat from quxian where county='"&startrs("当前地点")&"'"
stopsql="select lon,lat from quxian where county='"&startrs("终点地点")&"'"
set startrs=conn.execute(startsql)
startlon=startrs("lon")
startlat=startrs("lat")
set stoprs=conn.execute(stopsql)
stoplon=stoprs("lon")
stoplat=stoprs("lat")
startrs.close
stoprs.close
'结束读取数据库中的经纬点

%>

<script type="text/javascript">
//调用Google Map Api的计算距离函数
var distance = new GLatLng(<%=startlat%>, <%=startlon%>).distanceFrom(new GLatLng(<%=stoplat%>, <%=stoplon%>));
distance=parseInt(distance/1000,10)
//通过地址栏把distance的结果传递给asp
window.location.href="<%=Request.ServerVariables("SCRIPT_NAME")%>?name=" + distance + "&dd="+<%=bianhao%>
</script>
<%


end If
'接收js的数据
juli= Request.QueryString("name")
ddbianhao= Request.QueryString("dd")
<!--#include file="../../../conn/conn.asp"-->
julisql="update 业务订单 set 终点距离="&juli&" where 订单编号='"&ddbianhao&"'"
conn.execute(julisql)

%>

...全文
67 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
salecn 2010-08-12
  • 打赏
  • 举报
回复
感谢前辈指点!
灬上海爽爷 2010-08-12
  • 打赏
  • 举报
回复
可用JS设置页面每隔多少刷新一次

把你的代码加入到这个页面中

<script language="JavaScript">
function myrefresh()
{
window.location.reload();
}
setTimeout(''myrefresh()'',5000); //指定5秒刷新一次
</script>

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧