当前位置: 首页 > 图文教程 > 网络编程 > ASP > 关于Adodb.Stream的写数据库数据到客户端文件的实践

ASP
asp中常用的文件处理函数
正确处理ASP动态网页中的容错机制
asp自动生成javascript检验函数
如何避免asp的SQL的执行效率低
编译asp应用程序成为exe文件
ASP完成小偷程序机制和简略示例
ASP技巧:rs.getrows方法
ASP简单实现数字字符混合验证码
ASP技巧 挂QQ的网页源代码ASP/PHP
ASP实例:用ASP判断文件地址是否有效
ASP实例:使用ASP生成图片彩色校验码
ASP如何跳出本次进入下一次循环
ASP读取数据库中数据到数组的类
为你的ASP程序作一个负载测试
如何用ASP来获取客户端真实IP的地址
asp脚本运行超时的解决办法
ASP缓存类 【先锋缓存类】Ver2004
ASP动态包含文件的改进方法
ASP中利用application实现缓存
ASP Application 对象用户手册

ASP 中的 关于Adodb.Stream的写数据库数据到客户端文件的实践


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 72 ::
收藏到网摘: n/a

 

    这是一个从服务器数据库直接下数据到客户端文件的例子,文件名和扩展名可以根据需要随便写。new/temp.htm要求真实存在,其实没有什么作用,只是引导一下,否则不能对stram数据进行写操作。
    网络上流传的这方面的东西不少,但多数是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