Asp Access 建立靜態檔案/HTML

來源:互聯網
上載者:User

作用說明:
本代碼實現從 Access 提取資料以建立 HTML 檔案, 不建檔案夾.
如果檔案名稱與要建立的檔案名稱相同, 則覆蓋, 跟 SQL 的更新一樣的原理.

待加功能: 刪除與尋找. 複製代碼 代碼如下:<%
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' subject : Asp 建立靜態檔案/HTML By Stabx
'
' writer : Stabx<shawl.qiu@gmail.com>
'
' blog : http://btbtd.exblog.jp/ ;
'
' blog/site : Phoenix.GI - P.GI / \ 綠色學院 - Green Institute
'
' date : 2006-5-22
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select top 10 * from (select top 3500 * from ctarticle order by articleid asc) order by articleid desc" '子查詢, 目前被認為比恐龍還恐龍
rs.Open sql, MM_conn_string,1
while not rs.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("www")
'au_=htmlToText(rs("writer"))

response.write "<a href=""" & cid_ & "_"&ncid_&"_"&aid_&".htm"" target=""_blank"">"&cid_ & "_"&ncid_&"_"&aid_& ".htm</a> created at " & now() & "<br>" '連結建立好的檔案

cfilename= cid_& "_"&ncid_&"_"&aid_& ".htm" '命名要建立的檔案名稱

set dfso = createobject("scripting.filesystemobject")
Set chtml = dfso.CreateTextFile(server.mappath(cfilename), true)'存在即覆蓋
chtml.WriteLine("<html><head>")
chtml.WriteLine("<link rel='stylesheet' type='text/css' href='../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("created by cid:"&cid_&" ncid:"&ncid_&" aid:"&aid_&"
")
aid_=clng(aid_)
chtml.WriteLine("Page created on: " & now ())
chtml.WriteLine("</body></html>")
chtml.close
rs.movenext
wend
rs.close
set rs=nothing %>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.