果洛皆料电子有限公司

關(guān)于Adodb.Stream的寫數(shù)據(jù)庫數(shù)據(jù)到客戶端文件的實(shí)踐

  • 發(fā)布于:2020-05-31
  • 266 人圍觀
這是一個(gè)從服務(wù)器數(shù)據(jù)庫直接下數(shù)據(jù)到客戶端文件的例子,文件名和擴(kuò)展名可以根據(jù)需要隨便寫。new/temp.htm要求真實(shí)存在,其實(shí)沒有什么作用,只是引導(dǎo)一下,否則不能對(duì)stram數(shù)據(jù)進(jìn)行寫操作。
   網(wǎng)絡(luò)上流傳的這方面的東西不少,但多數(shù)是copy來的,很簡(jiǎn)單的事情搞得那么復(fù)雜。真正經(jīng)過實(shí)踐的東東少得可憐。于是自己寫了一個(gè),雖然簡(jiǎn)單,也有些問題,但是copy下去就可以用了。有問題的朋友可以跟我聯(lián)系,好一起學(xué)習(xí)。
  
  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 "賬號(hào)"
   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
萬企互聯(lián)
標(biāo)簽: