[thelist] Retrieving OLE File from Access DB with Classic ASP

Chris evolt at cubeit.co.uk
Mon Dec 19 06:02:32 CST 2005

Sorry, lack of explanation is because I hadn't written any code to try and
pull the PDF from the database as I don't know how.

I just had a play and the following code [left out the database connection
bits] will open the PDF in the browser [IE and Mozilla]:

Response.Buffer = True
Response.ContentType = oRs("fldFileType")
Response.BinaryWrite oRs("fldBinaryData")

I was looking for an option to force the browser to download the data.
There are plenty of examples of streaming a file from the filesystem but not
for lifting binary data from a database then streaming it to the browser.

I've tried using:

Dim objStream, myContents, myFileName

myFileName = "file.txt"

Response.ContentType = "application/octet-stream"
Response.AddHeader "content-disposition", "attachment; filename=" &

Set objStream = Server.CreateObject("ADODB.Stream")

myContents = oRs("fldBinaryData")

Response.BinaryWrite myContents

Set objStream = Nothing

The ADODB Stream does not like being set to the database field and throws a
type mismatch error.  I suspect it will only work being fed a file from the

Thanks for the help so far.

> -----Original Message-----
> From: thelist-bounces at lists.evolt.org [mailto:thelist-
> bounces at lists.evolt.org] On Behalf Of Ian Anderson
> Sent: 19 December 2005 09:39
> To: thelist at lists.evolt.org
> Subject: Re: [thelist] Retrieving OLE File from Access DB with Classic ASP
> Chris wrote:
> > I'd like to be able to provide options to open the PDF in a browser
> window
> > and to stream it to the client's browser as a 'save to' option.
> You haven't said what actually happens in the browser when you try your
> code.
> Does it fill the screen with garbage, or give an error message?
> I'm wondering about setting content-type in the header, or something
> like that - the browser is expecting html or image data, but may be
> receiving the raw binary data from the PDF and trying to interpret it
> using its default settings.
> More explanation of what is seen to be happening would surely help
> Cheers
> Ian
> --
> _________________________________________________
> zStudio - Web development and accessibility
> http://zStudio.co.uk
> Snippetz.net BETA - Online code library
> File, manage and re-use your code snippets online
> http://snippetz.net
> --
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !

More information about the thelist mailing list