如何实现asp中调用数据库内容并生成静态页面?并放在固定的文件夹内。

来源:百度知道 编辑:UC知道 时间:2024/05/17 18:32:49
调用数据库内容,生成静态页面,放在固定的文件夹内,并输入到数据库。

1.操作数据库使用ADO组件

常用写法示例...
<%
set cn = createobject("adodb.connection")
cn.open "数据库连接字符串"
set rs = cn.execute("select * from 表名")
do while not rs.eof
response.write rs(0) & " " & rs(1) '......
rs.movenext
loop
rs.close
set rs = nothing
cn.close
set cn = nothing
%>

2.取到数据后, 将数据嵌进HTML字符串内

如: str = "<html><head><title>示例</title></head><body>" & 取得的字符串 & "</body></html>"

3.使用FileSystemObject组件, 在指定文件夹下创建文件, 把组织好的html字符串写进文件.

<%
set fso = createobject("scripting.filesystemobject")
set fs = fso.createtextfile("d:\test.htm", true, false)
fs.write str
fs.close
set fs = nothing
set fso = nothing
%>

替换模版,烦