用ASP將SQL搜索出來的內(nèi)容導(dǎo)出為TXT的代碼
更新時(shí)間:2007年07月27日 15:36:58 作者:
<!--#include file="inc/conn.asp"-->
<%
dim rs,sql,filename,fso,myfile,x
Set fso = server.CreateObject("scripting.filesystemobject")
filename = Server.MapPath("download.txt")
if fso.FileExists(filename) then
fso.DeleteFile(filename)
end if
'--創(chuàng)建txt文件
set myfile = fso.CreateTextFile(filename,true)
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from userfile"
rs.Open sql,conn,1,1
if rs.EOF and rs.BOF then
response.write "無數(shù)據(jù)"
else
dim strLine,responsestr
strLine=""
'--將表的列名先寫入txt
For each x in rs.fields
strLine = strLine & x.name & chr(9)
Next
myfile.writeline strLine
Do while Not rs.EOF
strLine=""
for each x in rs.Fields
strLine = strLine & x.value & chr(9)
next
'--將表的數(shù)據(jù)寫入txt
myfile.writeline strLine
rs.MoveNext
loop
end if
rs.Close
set rs = nothing
Response.ContentType="application/x-msdownload"
Response.Redirect "download.txt"
%>
<%
dim rs,sql,filename,fso,myfile,x
Set fso = server.CreateObject("scripting.filesystemobject")
filename = Server.MapPath("download.txt")
if fso.FileExists(filename) then
fso.DeleteFile(filename)
end if
'--創(chuàng)建txt文件
set myfile = fso.CreateTextFile(filename,true)
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from userfile"
rs.Open sql,conn,1,1
if rs.EOF and rs.BOF then
response.write "無數(shù)據(jù)"
else
dim strLine,responsestr
strLine=""
'--將表的列名先寫入txt
For each x in rs.fields
strLine = strLine & x.name & chr(9)
Next
myfile.writeline strLine
Do while Not rs.EOF
strLine=""
for each x in rs.Fields
strLine = strLine & x.value & chr(9)
next
'--將表的數(shù)據(jù)寫入txt
myfile.writeline strLine
rs.MoveNext
loop
end if
rs.Close
set rs = nothing
Response.ContentType="application/x-msdownload"
Response.Redirect "download.txt"
%>
相關(guān)文章
前端在線預(yù)覽PDF文件三種實(shí)現(xiàn)方式(兼容移動端)
這篇文章主要介紹了前端在線預(yù)覽PDF文件三種實(shí)現(xiàn)方式的相關(guān)資料,分別是使用微軟在線預(yù)覽地址、直接使用window.open打開文檔鏈接以及使用PDF.js,PDF.js方法穩(wěn)定,適用于大多數(shù)文件,每種方法都給出了詳細(xì)的代碼示例,需要的朋友可以參考下2025-02-02
WordPress中利用AJAX技術(shù)進(jìn)行評論提交的實(shí)現(xiàn)示例
這篇文章主要介紹了WordPress中利用AJAX技術(shù)進(jìn)行評論提交的實(shí)現(xiàn)示例,整個(gè)處理的關(guān)鍵點(diǎn)在于文中的ajax_comment函數(shù),需要的朋友可以參考下2016-01-01
javascript實(shí)現(xiàn)電商放大鏡效果
這篇文章主要為大家詳細(xì)介紹了javascript實(shí)現(xiàn)電商放大鏡效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-11-11
DOM操作原生js 的bug,使用jQuery 可以消除的解決方法
下面小編就為大家?guī)硪黄狣OM操作原生js 的bug,使用jQuery 可以消除的解決方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-09-09

