Asp Access 创建静态文件HTML
2018-09-06 12:50
作用说明:
本代码实现从Access提取数据以创建HTML文件,不建文件夹.
如果文件名与要创建的文件名相同,则覆盖,跟SQL的更新一样的原理.
待加功能:删除与查找.
复制代码 代码如下:
<%
subject:Asp创建静态文件/HTMLByStabx
blog:
blog/site:Phoenix.GI-P.GI/\绿色学院-GreenInstitute
date:2006-5-22
Setrs=Server.CreateObject(ADODB.Recordset)
sql=selecttop10*from(selecttop3500*fromctarticleorderbyarticleidasc)orderbyarticleiddesc子查询,目前被认为比恐龙还恐龙
rs.Opensql,MM_conn_string,1
whilenotrs.eof循环创建查询的全部记录为HTML文件
cid_=rs(classid)
ncid_=rs(nclassid)
aid_=rs(articleid)
adt_=rs(dateandtime)
tt_=rs(title)
ct_=rs(content)
em_=htmlToText(rs(email))
ht_=rs(hits)
url_=rs(url)
src_=rs(
au_=htmlToText(rs(writer))
response.write<ahref=&cid_&_&ncid_&_&aid_&.htm>&cid_&_&ncid_&_&aid_&.htm</a>createdat&now()&<br>链接创建好的文件
cfilename=cid_&_&ncid_&_&aid_&.htm命名要创建的文件名
setdfso=createobject(scripting.filesystemobject)
Setchtml=dfso.CreateTextFile(server.mappath(cfilename),true)存在即覆盖
chtml.WriteLine(<html><head>)
chtml.WriteLine(<linkrel=stylesheettype=text/csshref=../css/css_first/ctarticle.css>)
chtml.WriteLine(<title>&sitename_&&tt_&</title>)
chtml.WriteLine(</head><body>)
chtml.WriteLine(title:&tt_&<p/>)
chtml.WriteLine(content:&ct_&<p/>)
chtml.WriteLine(createdbycid:&cid_&ncid:&ncid_&aid:&aid_&
)
aid_=clng(aid_)
chtml.WriteLine(Pagecreatedon:&now())
chtml.WriteLine(</body></html>)
chtml.close
rs.movenext
wend
rs.close
setrs=nothing%>
文章标题:Asp Access 创建静态文件HTML
文章链接:http://soscw.com/index.php/essay/10732.html