This is an example of directly downloading data from the server database to the client file. The file name and extension can be written as needed. new/temp.htm requires real existence. In fact, it has no effect. It is just a guide. Otherwise, stram data cannot be written.
There are a lot of things in this area circulating on the Internet, but most of them are copied. Very simple things are made so complicated. There are very few things that have actually been put into practice. So I wrote one myself. Although it is simple and has some problems, it can be used after copying it. Friends who have questions can contact me so that we can learn together.
filemystream=server.mappath("new") & "temp.htm"
Set MyStream=Server.CreateObject("Adodb.Stream")
MyStream.Type = 1
MyStream.Mode=3
MyStream.Open
MyStream.LoadFromFile(filemystream)
Response.ContentType="application/octet-stream"
Response.AddHeader "Content-Disposition:","attachment; filename=" & "bk.txt"
Range=Mid(Request.ServerVariables("HTTP_RANGE"),7)
response.write "Name"
response.write "Account"
response.write "address"
response.write "Description"
cr=chr(13)&chr(10)
response.write(cr)
while not rs.eof
response.write rs("name")
response.write rs("accno")
response.write rs("address")
response.write rs("note")
response.write(cr)
RS.MoveNext
wend
rs.close
set rs=nothing
Conn.Close
Set Conn=Nothing
Mystream.close
set Mystream=nothing