<! -- # 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
'-- Create a txt file
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 "no data"
Else
Dim strLine, responsestr
StrLine = ""
'-- Write the table column name to txt first
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
'-- Write table data to txt
Myfile. writeline strLine
Rs. MoveNext
Loop
End if
Rs. Close
Set rs = nothing
Response. ContentType = "application/x-msdownload"
Response. Redirect "download.txt"
%>