The following code uses the ACCESS database as an example to demonstrate how to save files to the hard disk through ADODB. Stream.
Table: Demo Structure
========================================================
ID: Automatic ID
Filename: Text
Data: OLE object
Code
========================================================
<%
Dim Conn, connstr, RS, SQL, mystream
Connstr = "DBQ =" + server. mappath ("demo. mdb") + "; driver = {Microsoft Access Driver (*. mdb )};"
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open connstr
SQL = "select * from demo where id = 1"
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open SQL, Conn, 1, 3
Set mystream = server. Createobject ("ADODB. Stream ")
Mystream. type = 1
Mystream. Open
Mystream. Write RS ("data"). getchunk (RS ("data"). ActualSize-78)
Mystream. savetofile "C:/" & RS ("FILENAME ")
Rs. Close
Set rs = nothing
Conn. Close
Set conn = nothing
%>