Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: BLOB to MS Word via ASP/VBScript

Re: BLOB to MS Word via ASP/VBScript

From: DA Morgan <damorgan_at_psoug.org>
Date: Wed, 31 Oct 2007 14:15:25 -0700
Message-ID: <1193865323.191495@bubbleator.drizzle.com>


S. wrote:
> I've been researching this for two days without little success. I have
> an ASP that accesses an Oracle BLOB to extract MS Word documents
> (later to include excel, power point, pdf, and text). The document is
> stored there via Rational ClearCase.
>
> I'm able to access the data in the BLOB, but when I try to display it,
> all I get is the garbage-looking word format inside MS Word (as it
> would look if displayed in notepad or the browser itself). Any ideas,
> suggestions, pointers? I've tried several approaches with different
> types of errors (I'm new to ASPs and VBScript). For instance, when I
> try using ADODB.Stream, I can't seem to be able to write a file (to
> confirm I was opening the blob properly). The chosen directory does
> have open write permissions.
>
>
> set mstream = Server.CreateObject("ADODB.Stream")
> mstream.Type = 1 'adTypeBinary
> mstream.Open
> mstream.Write rs("data")
> mstream.SaveToFile "c:\test.doc", 2 'adSaveCreateOveWrite , also tried
> 1 for new file
> 'Response.BinaryWrite mstream.Read ' failes with type mismatch
>
>
> The most "successful" code is below. (There may be typos since I'm
> working on a separate test network and had to manually type the code
> here for posting. :-p)
>
> Using:
> ASP with VBScript
> IIS v??? (SysAdmin unavailable!)
> IE v5.5
> Oracle 10 (OraOLEDB.Oracle since MSDAORA.1 was not returning
> anything)
> ADODB.Connection
>
>
> <%
> dbid = request.QueryString("dbid")
> Dim rs, sql, conn
>
> 'Clear existing HTTP header information
> Reponse.expires = 0
> Response.Buffer = TRUE
> Reponse.Clear
>
> set conn = Server.CreateObject("ADODB.Connection")
> set rs = Server.CreateObject("ADODB.Recordset")
> conn.Open "Provider=OraOLEDB.Oracle;Data Source=oratest.rfc.net; User
> id=***;Password=***;"
>
> Reponse.ContentType = "application/msword"
>
> sql = "SELECT data FROM ATTACHMENTS_BLOB where ENTITY_DBID = '" & dbid
> "'"
> rs.open sql, conn
>
> Reponse.BinaryWrite rs("data") 'same results with .Value
>
> rs.close
> conn.close
>
> %>

Look at "Save BLOB to File Demo" here:
http://www.psoug.org/reference/dbms_lob.html

Thousands of other Oracle demos can be found here: http://www.psoug.org/library.html
including of UTL_FILE which can be used to write BLOB data to a file.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Wed Oct 31 2007 - 16:15:25 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US