asp从access导出为csv文件
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>export</title></head><!--#include file="../Include/Const.asp" --><!--#include file="../Include/ConnSiteData.asp" --> <body><%'设置页面时间Server.ScriptTimeOut=999999dim s,sql,filename,fs,myfile,x,mFileName,ObjExcel,ObjSheetSet fs = server.CreateObject("scripting.filesystemobject")filename = Server.MapPath("contact.csv")'--如果原来的EXCEL文件存在的话删除它if fs.FileExists(filename) thenfs.DeleteFile(filename)end if'--创建csv文件set myfile = fs.CreateTextFile(filename,true)'--从数据库中把你想放到csv中的数据查出来strSql = "select * from Ameav_Contact order by OrgName asc" '--显示执行的SQL语句Response.Write "<div id='sql'><strong>SQL 语句:</strong><br />"&strSql&"</div>"Set Rs =conn.execute(strSql)if not Rs.EOF and not Rs.BOF thendim trLine,responsestrstrLine=""For each x in Rs.fieldsstrLine = "OrgName,DepName,StaffName,Office,SubPhone,DirecPhone,Telephone,PersonEmail,CompanyEmail,Password,Remark"'Public,Password,Remark"Nextmyfile.writeline strLineResponse.Write "<div id='data'>"Do while Not Rs.EOFstrLine=""strLine= Rs("OrgName")&"," & Rs("DepName")&"," & Rs("StaffName") & "," & Rs("Office") & "," & Rs("SubPhone") & "," & Rs("DirecPhone") & "," & Rs("Telephone") & "," & Rs("PersonEmail") & "," & Rs("CompanyEmail") & "," & Rs("Password") & "," & Rs("Remark")'& Rs("Public") & "," & Rs("Password") & "," & Rs("Remark")if WriteDB=True thenResponse.Write strLine & "<br /><hr />"end ifmyfile.writeline strLineRs.MoveNextloopResponse.Write "</div>"end ifResponse.Write "<div id='down'><p><a href=""contact.csv"" target=""_blank"">生成文件成功,点击下载!</a></p></div>"Rs.Close :set Rs = nothingConn.Close:Set Conn = nothing%></body></html>