asp转html问题

来源:百度知道 编辑:UC知道 时间:2024/05/24 00:43:22
数据库有多条记录
下面语句为什么只能执行一次,要是记录有多条就会出错,请问要怎么解决
要根据时间生产时间目录下的多个文件
<%
sql="select * from c_news order by c_id desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
do while not rs.eof
'生成HTML文件名,建立文件夹,指定文件路径
datetime=FormatDateTime(rs("c_time"),2)&"/"
fname=makefilename(rs("c_time"))
filepath =datetime&fname
'生成HTML页面
Set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.CreateFolder(Server.MapPath(datetime))'不存在则创建CityHtml文件夹
Set fout = fso.CreateTextFile(Server.MapPath(filepath))
fout.WriteLine mb_code
fout.close
Response.Write(""&datename&"")
Response.Write("<br />")
rs.MoveNext
Loop

rs.close
set rs=nothing
%>

这段代码是以文章日期为名称生成文件夹的,注意你数据表中日期的格式,我刚刚看了一下,这个代码没什么问题,不过你的时间格式应该是2006-6-22类似这种.

把你的文件名每次加一个4位随意字符,应该就可以了