日期:2014-05-17  浏览次数:21595 次

这个asp生成静态文件的代码哪有错误啊?急
<!--#include file="conn.asp"-->
<%
dim title,content,id

if reguest("id")="" then
 id=0
else
id=reguest("id")

Dim fso,f,htmlpath,mobanpath,tmppath
Dim strTitle,strContent,strOut
'创建文件系统对象
htmlpath=Server.MapPath("html")
mobanpath=Server.MapPath("cmoban.html")
Set fso=Server.CreateObject("Scripting.FileSystemObject")

Set f=fso.OpenTextFile(Server.MapPath("cmoban.html")) '打开网页模板文件,读取模板内容
strOut=f.ReadAll
f.close

set rs=server.CreateObject("ADODB.RecordSet")
rs.Source="select top 50 * from jingdian where id > " & id & "by order by id"
rs.Open rs.Source,Conn,1,1


Do While not rs.eof '貌似这个循环有问题。不过不知道怎么错的
tmppath = htmlpath & "\" & rs("s_id") & "\" &rs("o_id") '定义路径
 if not fso.folderExists(tmppath) then 
fso.creasteFolder(tmppath) '创建文件夹
end if
title=rs("title")
content=rs("content")
strTitle = title
strContent= content
strOut=Replace(strOut,"$title$",strTitle) '替换strOut字符串中的$title$
strOut=Replace(strOut,"$xiangqing$",strContent) '替换
Set f=fso.CreateTextFile(tmppath&"\" & rs("id") & ".html") '创建要生成的静态页
f.WriteLine strOut '写入网页内容
f.close ' 关闭文件对象
set f=Nothing '释放文件系统对象
if not rs.eof then 
 rs.movenext '移到下一个记录
end if

Loop
id=rs("id") '记录当前已创建了的ID值用于下页更新
rs.close
set rs=nothing

set fso=Nothing
%>
<%
Response.Write ("已更新了" & id & "个景点信息!")
%>


<script language="javascript">
location="updataall.asp?id=<% = id %> " ;
</script>



------解决方案--------------------
大概浏览了一下 发现两个问题
1. reguest 应为 request

2. "select top 50 * from jingdian where id > " & id & "by order by id" 里面order 前面的by应该不需要

------解决方案--------------------
if reguest("id")="" then
 id=0

。。。。。。
。。。

没有对应的 end if
------解决方案--------------------
if reguest("id")="" then
 id=0
else
后面没有end if


if not rs.eof then
 rs.movenext '移到下一个记录
end if
这个判断是多余的,你前面的do while not rs.eof就已经帮你判断了


Loop
id=rs("id") 
循环完了,记录集已经到最后了,这个时候再取rs("id")还取得到吗?