这是一段下载信息文件的程序,但是一运行出现了以下错误:
请问这是为什么?能否帮帮小弟?!感激中~~~~~~~~ <!--#include virtual="/Conn.asp"--> <% Class OutPutWord public sFileName '文件名 public sWordContent '@内容 Private adTypeBinary,pvFileName,svFileName '随机名称,'绝对名称 Private objStream,thefile,fso Private Sub Class_Initialize() adTypeBinary = 1 End Sub Private function WriteTxtfile(thedatafile,texts) on error resume next set fso=server.CreateObject("scripting.filesystemobject") set thefile=fso.CreateTextFile (thedatafile) thefile.write(texts) thefile.close set thefile=nothing set fso=nothing end function Private function getRand() Randomize '初始化随机数生成器。 p1=1000 p2=9999 getRand = INT((p2-p1 + 1)*RND+p1) end function Public function OutAction() pvFileName = "/Word/" & year(now) & "-" & month(now) & "-" & day(now) & "-" & getRand()&".doc" svFileName = Server.Mappath(pvFileName) Call WriteTxtfile(svFileName,sWordContent) Set objStream = Server.CreateObject("ADODB.Stream") objStream.Open objStream.Type = adTypeBinary objStream.LoadFromFile svFileName 'change the path if necessary Response.ContentType = "application/octet-stream" Response.AddHeader "Content-Disposition", "attachment; filename=" & sFileName & ".doc" '如果文件名固定,那就直接filename=文件名.doc,这个名字就是用户选“保存”时,出现的名字 Response.BinaryWrite objStream.Read Response.Flush objStream.Close Set objStream = Nothing '写完,释放对象 Call DelFile(svFileName) end function Private function DelFile(FilePath) Set fso = Server.CreateObject("Scripting.FileSystemObject") If fso.FileExists(FilePath) Then fso.DeleteFile(FilePath) End If Set fso=Nothing end function End Class' dim myWord ' set myWord = new OutPutWord ' myWord.sFileName = "导出" ' myWord.sWordContent="硒鼓可耕地"&chr(13)&"a大草原" ' myWord.OutAction()
if Session("UserLogin")<>true then Call ScriptRedircet("你还没登陆,请登陆!","/") end if
ClassID = Trim(Request("ClassID")) p = Trim(Request("p")) dim strContent strContent = "" if ClassID = "已阅读未回复" then Set rsC=Server.CreateObject("Adodb.RecordSet") sql=" SELECT TOP 10 A.UserName, B.XinXiBiaoTi,B.XinXiNeiRong, B.TimeDate " & _ " FROM MyData_26 A INNER JOIN " & _ " MyData_52 B ON A.ID = B.TopID " & _ " WHERE (B.IsChaKan = 1) AND (B.ShouXinRen = "&Session("UserNameID")&") AND (B.XinXiBiaoTi <> N'系统消息') AND (B.ReturnID = 0) AND " & _ " (B.SelfDo = 0) " & _ " ORDER BY B.TimeDate" rsC.open sql,conn,1,3 if not rsC.eof then do while not rsC.eof strContent = strContent & "时间:" & rsC("TimeDate") & vbCrLf & _ "网友:" & rsC("UserName") & vbCrLf & _ "标题:" & rsC("XinXiBiaoTi") & vbCrLf & _ "内容:" & rsC("XinXiNeiRong")& vbCrLf & vbCrLf rsC.movenext loop else strContent = "暂无信息!" end if rsC.close set rsC = nothing if p = "0" then SQL = "Delete from MyData_52 where (IsChaKan = 1) AND (ShouXinRen = "&Session("UserNameID")&") AND (XinXiBiaoTi <> N'系统消息') AND (ReturnID = 0) AND (SelfDo = 0) " Conn.execute(SQL) end if End if
dim myWord set myWord = new OutPutWord myWord.sFileName = Session("UserName")&"的信息导出" myWord.sWordContent = strContent myWord.OutAction() %>