关于Adodb.Stream的写数据库数据到客户端文件的实践
- 发布于:2020-05-31
- 共 203 人围观
网络上流传的这方面的东西不少,但多数是copy来的,很简单的事情搞得那么复杂。真正经过实践的东东少得可怜。于是自己写了一个,虽然简单,也有些问题,但是copy下去就可以用了。有问题的朋友可以跟我联系,好一起学习。
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 "姓名"
response.write "账号"
response.write "地址"
response.write "说明"
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