<%
dim filename
filename="love" '定义要生成的.html文件名
set fso=server.CreateObject("Scripting.FileSystemObject") '创建文件对像
path=server.MapPath("docu/"&filename&".html") '确定创建文件路径
if fso.FileExists(path)=true then '如果该文件存在就删除此文件
fso.DeleteFile(path)
end if
set fso=nothing
path=server.MapPath("docu") '确定创建文件路径
set fso=server.CreateObject("Scripting.FileSystemObject") '创建文件路径
if fso.FolderExists(path)=false then ' 如果该目录不存在创建此目录
fso.CreateFolder(path)
end if
path=path&"/"&filename&".html" '确定要生成文件名称
Set rs = Server.CreateObject("ADODB.Recordset") '打开数据库取出要操作的记录集
sql ="Select top 5 * From data Order By id DESC"
RS.open sql,Conn,1,1 '执行语句
set ts=fso.OpenTextFile(path,2,true,-2) '开始创建文件
ts.writeline"<!--#include file=""template/sample_1.inc""-->" '调用已经做好的文件模板
ts.writeline"<link href=""../style.css"" rel=""stylesheet"" type=""text/css"">"
ts.writeline"<table border=""0"" cellpadding=""1"" cellspacing=""0"" width=""100%"" height=""170"">" '这里是标准的html文件有,但要注意语法
ts.writeline"<tr><td colspan=""2""><p align=""center"">"
ts.writeline"<!--Newsboy.Title-->" '这里是标准.html注释
do while not rs.eof
con1=""&rs("pass")&""
ts.writeline"<!--Newsboy.Title--></td></tr><tr>"
ts.writeline"<td colspan=""2""></td></tr><tr><td>"
ts.writeline" <a href=""http://book.hengshui.com/music00/getcard.asp?id="&con1&" "" target=_blank> <font color=""red"">"
ts.writeline rs("myname")
ts.writeline "</font>为<font color=""green"">"
ts.writeline rs("toname")
ts.writeline "</font>点歌<br> ["
ts.writeline rs("titletext")
ts.writeline "]</a><br>"
ts.writeline"</td><td><p align=""right"">"
ts.writeline"</td></tr><tr>"
RS.MoveNext
Loop
ts.writeline"<td colspan=""2"">"
ts.writeline"</td></tr></table>"
ts.writeline"<!--#include file=""template/sample_2.inc""-->"'调用已经做好的文件模板
ts.close
set ts=nothing '删除创建的对象
set fso=nothing
rs.Close
set rs=nothing
%>