About ADODB.stream Write database data to the client

Source: Internet
Author: User
Tags chr copy client
ado|stream| Client | data | database

This is an example of data from the server database directly to the client file, and the filename and extension can be written casually as needed. New/temp.htm requires real existence, in fact, does not have any effect, just guide, otherwise can not stram data write operation.
There are a lot of things that are circulating on the Internet, but most of them are copy, and it's very simple to make things so complicated. The things that really go through practice are so few and pitiful. So I wrote a, although simple, there are some problems, but copy down can be used. Friends with problems can contact me to study 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 (&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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.