谁来帮忙解决一下代码,关于asp中生成html文件,高分,在线急等。。。
<!--#includefile="../include/function.asp"--><!--#includefile="conn.asp"--><%dimtitle...
<!--#include file="../include/function.asp"-->
<!--#include file="conn.asp"-->
<%
dim title,rstitle,sqltitle,urll
PVid=request.querystring("PVid")
Pid=request.querystring("Pid")
set rstitle = server.createobject("adodb.recordset")
sqltitle = "select * from title where id=1"
rstitle.open sqltitle,conn,1,1
title=rstitle("title")
urll=rstitle("url")
dim myweekday,dayname
myweekday=weekday(now())
select case myweekday
case "1"
dayname="星期日"
case "2"
dayname="星期一"
case "3"
dayname="星期二"
case "4"
dayname="星期三"
case "5"
dayname="星期四"
case "6"
dayname="星期五"
case "7"
dayname="星期六"
end select
dim yea,mont,da
yea=year(now())
mont=month(now())
da=day(now())
dim html,nav
Index=request.form("html_name")
Response.Charset = "UTF-8"
set rst = server.createobject("adodb.recordset")
sqlt="select * from nav where nav_b="&true&" and x_y="&true
rst.open sqlt,conn,1,1
if rst.recordcount=0 then
response.Write("...没有相关的信息 <<<")
else
do while not rst.eof
nav = nav &"<a href='"&rst("nav_url")&"' target='"&rst("target")&"'>"&rst("nav_name")&"</a>"
rst.movenext
loop
end if
'这个ASP文件时获取数据库里的信息
sub addhtml(filename)
dim fso,readrs,tplurl,content
tplurl = "..\index_detail.dwt"
set fso = server.createobject("scripting.filesystemobject")
set readts = fso.opentextfile(server.mappath(tplurl),1)
'如果这个模版里有代码的话,就读出全部放到变量里去
if not readts.atendofstream then
content = readts.readall
end if
readts.close
set readts = nothing
content = replace(content,"{title}",title)
content = replace(content,"{urll}",urll)
content = replace(content,"{dayname}",dayname)
content = replace(content,"{year}",yea)
content = replace(content,"{month}",mont)
content = replace(content,"{day}",da)
content = replace(content,"{nav}",nav)
set writets = fso.opentextfile(server.mappath("\"&filename),2,true)
writets.writeline(content) ’第 126 行 --出错改行
writets.close
set writets = nothing
set fso = nothing
end sub
dim fso,filename
filename = Index & ".html"
set fso = server.createobject("scripting.filesystemobject")
'这个静态文件是否存在
if fso.folderexists(server.mappath(filename)) then
sub delstatic(url)
set fso = server.createobject("scripting.filesystemobject")
'文件存在,就进行删除
fso.deletefile(server.mappath("../"&url))
set fso = nothing
end sub
else
'如果不存在,写入HTML
call addhtml(filename)
end if
set fso = nothing
response.write("<script>alert('"& filename &" ,生成成功!');location.href='admin_html.asp'</script>")
%>
Microsoft VBScript 运行时错误 (0x800A0005)
无效的过程调用或参数
/admin/admin_html.asp, 第 126 行
自己解决了
谢谢大家。。。 展开
<!--#include file="conn.asp"-->
<%
dim title,rstitle,sqltitle,urll
PVid=request.querystring("PVid")
Pid=request.querystring("Pid")
set rstitle = server.createobject("adodb.recordset")
sqltitle = "select * from title where id=1"
rstitle.open sqltitle,conn,1,1
title=rstitle("title")
urll=rstitle("url")
dim myweekday,dayname
myweekday=weekday(now())
select case myweekday
case "1"
dayname="星期日"
case "2"
dayname="星期一"
case "3"
dayname="星期二"
case "4"
dayname="星期三"
case "5"
dayname="星期四"
case "6"
dayname="星期五"
case "7"
dayname="星期六"
end select
dim yea,mont,da
yea=year(now())
mont=month(now())
da=day(now())
dim html,nav
Index=request.form("html_name")
Response.Charset = "UTF-8"
set rst = server.createobject("adodb.recordset")
sqlt="select * from nav where nav_b="&true&" and x_y="&true
rst.open sqlt,conn,1,1
if rst.recordcount=0 then
response.Write("...没有相关的信息 <<<")
else
do while not rst.eof
nav = nav &"<a href='"&rst("nav_url")&"' target='"&rst("target")&"'>"&rst("nav_name")&"</a>"
rst.movenext
loop
end if
'这个ASP文件时获取数据库里的信息
sub addhtml(filename)
dim fso,readrs,tplurl,content
tplurl = "..\index_detail.dwt"
set fso = server.createobject("scripting.filesystemobject")
set readts = fso.opentextfile(server.mappath(tplurl),1)
'如果这个模版里有代码的话,就读出全部放到变量里去
if not readts.atendofstream then
content = readts.readall
end if
readts.close
set readts = nothing
content = replace(content,"{title}",title)
content = replace(content,"{urll}",urll)
content = replace(content,"{dayname}",dayname)
content = replace(content,"{year}",yea)
content = replace(content,"{month}",mont)
content = replace(content,"{day}",da)
content = replace(content,"{nav}",nav)
set writets = fso.opentextfile(server.mappath("\"&filename),2,true)
writets.writeline(content) ’第 126 行 --出错改行
writets.close
set writets = nothing
set fso = nothing
end sub
dim fso,filename
filename = Index & ".html"
set fso = server.createobject("scripting.filesystemobject")
'这个静态文件是否存在
if fso.folderexists(server.mappath(filename)) then
sub delstatic(url)
set fso = server.createobject("scripting.filesystemobject")
'文件存在,就进行删除
fso.deletefile(server.mappath("../"&url))
set fso = nothing
end sub
else
'如果不存在,写入HTML
call addhtml(filename)
end if
set fso = nothing
response.write("<script>alert('"& filename &" ,生成成功!');location.href='admin_html.asp'</script>")
%>
Microsoft VBScript 运行时错误 (0x800A0005)
无效的过程调用或参数
/admin/admin_html.asp, 第 126 行
自己解决了
谢谢大家。。。 展开
5个回答
展开全部
<!--#include file="../include/function.asp"-->
<!--#include file="conn.asp"-->
<%
dim title,rstitle,sqltitle,urll
PVid=request.querystring("PVid")
Pid=request.querystring("Pid")
set rstitle = server.createobject("adodb.recordset")
sqltitle = "select * from title where id=1"
rstitle.open sqltitle,conn,1,1
title=rstitle("title")
urll=rstitle("url")
dim myweekday,dayname
myweekday=weekday(now())
select case myweekday
case "1"
dayname="星期日"
case "2"
dayname="星期一"
case "3"
dayname="星期二"
case "4"
dayname="星期三"
case "5"
dayname="星期四"
case "6"
dayname="星期五"
case "7"
dayname="星期六"
end select
dim yea,mont,da
yea=year(now())
mont=month(now())
da=day(now())
dim html,nav
Index=request.form("html_name")
Response.Charset = "UTF-8"
set rst = server.createobject("adodb.recordset")
sqlt="select * from nav where nav_b="&true&" and x_y="&true
rst.open sqlt,conn,1,1
if rst.recordcount=0 then
response.Write("...没有相关的信息 <<<")
else
do while not rst.eof
nav = nav &"<a href='"&rst("nav_url")&"' target='"&rst("target")&"'>"&rst("nav_name")&"</a>"
rst.movenext
loop
end if
'这个ASP文件时获取数据库里的信息
sub addhtml(filename)
dim fso,readrs,tplurl,content
tplurl = "..\index_detail.dwt"
set fso = server.createobject("scripting.filesystemobject")
set readts = fso.opentextfile(server.mappath(tplurl),1)
'如果这个模版里有代码的话,就读出全部放到变量里去
if not readts.atendofstream then
content = readts.readall
end if
readts.close
set readts = nothing
content = replace(content,"{title}",title)
content = replace(content,"{urll}",urll)
content = replace(content,"{dayname}",dayname)
content = replace(content,"{year}",yea)
content = replace(content,"{month}",mont)
content = replace(content,"{day}",da)
content = replace(content,"{nav}",nav)
set writets = fso.opentextfile(server.mappath(filename),2,true)
writets.writeline(content) '第 126 行 --出错改行
writets.close
set writets = nothing
set fso = nothing
end sub
dim fso,filename
filename = Index & ".html"
set fso = server.createobject("scripting.filesystemobject")
call addhtml(filename)
set fso = nothing
response.write("<script>alert('"& filename &" ,生成成功!');location.href='admin_html.asp'</script>")
%>
<!--#include file="conn.asp"-->
<%
dim title,rstitle,sqltitle,urll
PVid=request.querystring("PVid")
Pid=request.querystring("Pid")
set rstitle = server.createobject("adodb.recordset")
sqltitle = "select * from title where id=1"
rstitle.open sqltitle,conn,1,1
title=rstitle("title")
urll=rstitle("url")
dim myweekday,dayname
myweekday=weekday(now())
select case myweekday
case "1"
dayname="星期日"
case "2"
dayname="星期一"
case "3"
dayname="星期二"
case "4"
dayname="星期三"
case "5"
dayname="星期四"
case "6"
dayname="星期五"
case "7"
dayname="星期六"
end select
dim yea,mont,da
yea=year(now())
mont=month(now())
da=day(now())
dim html,nav
Index=request.form("html_name")
Response.Charset = "UTF-8"
set rst = server.createobject("adodb.recordset")
sqlt="select * from nav where nav_b="&true&" and x_y="&true
rst.open sqlt,conn,1,1
if rst.recordcount=0 then
response.Write("...没有相关的信息 <<<")
else
do while not rst.eof
nav = nav &"<a href='"&rst("nav_url")&"' target='"&rst("target")&"'>"&rst("nav_name")&"</a>"
rst.movenext
loop
end if
'这个ASP文件时获取数据库里的信息
sub addhtml(filename)
dim fso,readrs,tplurl,content
tplurl = "..\index_detail.dwt"
set fso = server.createobject("scripting.filesystemobject")
set readts = fso.opentextfile(server.mappath(tplurl),1)
'如果这个模版里有代码的话,就读出全部放到变量里去
if not readts.atendofstream then
content = readts.readall
end if
readts.close
set readts = nothing
content = replace(content,"{title}",title)
content = replace(content,"{urll}",urll)
content = replace(content,"{dayname}",dayname)
content = replace(content,"{year}",yea)
content = replace(content,"{month}",mont)
content = replace(content,"{day}",da)
content = replace(content,"{nav}",nav)
set writets = fso.opentextfile(server.mappath(filename),2,true)
writets.writeline(content) '第 126 行 --出错改行
writets.close
set writets = nothing
set fso = nothing
end sub
dim fso,filename
filename = Index & ".html"
set fso = server.createobject("scripting.filesystemobject")
call addhtml(filename)
set fso = nothing
response.write("<script>alert('"& filename &" ,生成成功!');location.href='admin_html.asp'</script>")
%>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
给你个UTF-8的方法
<% dim TempString
TempString = "..\template\index.tpl"
content=ReadFromUTF(Template,"utf-8")
content=Replace(content,"{title}",title)
content=Replace(content,"{url}",url)
content=Replace(content,"{year}",yea)
content=Replace(content,"{month}",mont)
content=Replace(content,"{day}",da)
content=Replace(content,"{myweekday}",myweekday)
content=Replace(content,"{nav}",nav)
content=Replace(content,"{yrh}",yrh)
content=Replace(content,"{yh}",yh)
content=Replace(content,"{trh}",trh)
content=Replace(content,"{th}",th)
content=Replace(content,"{arh}",arh)
content=Replace(content,"{ah}",ah)
Filen="../" & Index
Call WriteToUTF(content,Filen)
If Not Err Then Response.Write "<script>window.location.href='admin_html.asp'</script>"
Function ReadFromUTF(TempString,CharSet)
Dim str
Set stm=server.CreateObject("adodb.stream")
stm.Type=2
stm.Mode=3
stm.Charset=CharSet
stm.Open
stm.loadfromfile Server.MapPath("..\template\index.tpl")
str=stm.readtext
stm.Close
Set stm=Nothing
ReadFromUTF=str
End Function
Function WriteToUTF(content,Filen)
Set objStream=Server.CreateObject("ADODB.Stream")
With objStream
.Open
.Charset="utf-8"
.Position=objStream.Size
.WriteText=content
.SaveToFile server.mappath(Filen),2
.Close
End With
Set objStream=Nothing
End Function
%>
<% dim TempString
TempString = "..\template\index.tpl"
content=ReadFromUTF(Template,"utf-8")
content=Replace(content,"{title}",title)
content=Replace(content,"{url}",url)
content=Replace(content,"{year}",yea)
content=Replace(content,"{month}",mont)
content=Replace(content,"{day}",da)
content=Replace(content,"{myweekday}",myweekday)
content=Replace(content,"{nav}",nav)
content=Replace(content,"{yrh}",yrh)
content=Replace(content,"{yh}",yh)
content=Replace(content,"{trh}",trh)
content=Replace(content,"{th}",th)
content=Replace(content,"{arh}",arh)
content=Replace(content,"{ah}",ah)
Filen="../" & Index
Call WriteToUTF(content,Filen)
If Not Err Then Response.Write "<script>window.location.href='admin_html.asp'</script>"
Function ReadFromUTF(TempString,CharSet)
Dim str
Set stm=server.CreateObject("adodb.stream")
stm.Type=2
stm.Mode=3
stm.Charset=CharSet
stm.Open
stm.loadfromfile Server.MapPath("..\template\index.tpl")
str=stm.readtext
stm.Close
Set stm=Nothing
ReadFromUTF=str
End Function
Function WriteToUTF(content,Filen)
Set objStream=Server.CreateObject("ADODB.Stream")
With objStream
.Open
.Charset="utf-8"
.Position=objStream.Size
.WriteText=content
.SaveToFile server.mappath(Filen),2
.Close
End With
Set objStream=Nothing
End Function
%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
try this, set a break on set writets = fso.opentextfile(server.mappath("\"&filename),2,true)
to see writets return anything.
to see writets return anything.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询