BLOB to MS Word via ASP/VBScript

Discussion in 'ASP General' started by S., Oct 31, 2007.

  1. S.

    S. Guest

    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

    %>
    S., Oct 31, 2007
    #1
    1. Advertising

  2. "S." <> wrote in message
    news:...
    > 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
    >
    > %>
    >


    This might seem like a daft question but the client does have Word installed
    right?
    You're comfortable that the content is Word and is stored with fidelity in
    the first place?


    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, Oct 31, 2007
    #2
    1. Advertising

  3. "S." <> wrote in message
    news:...
    > 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")


    You should write the value of the field to the stream, and then you must set
    the stream's position to 0, before trying to read it/pass the return to
    Response.BinaryWrite.


    > 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"


    The type should be "application/vnd.ms-word".


    -Mark



    > 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
    >
    > %>
    >
    Mark J. McGinty, Nov 3, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luis Esteban Valencia
    Replies:
    2
    Views:
    2,940
    sanjupillai
    Sep 26, 2008
  2. Nickname
    Replies:
    5
    Views:
    6,250
    Marcin Grunwald
    Mar 18, 2005
  3. Juergen Gerner

    Storing files in a BLOB field via SQL

    Juergen Gerner, Jun 6, 2004, in forum: Python
    Replies:
    7
    Views:
    1,893
    Martin Bless
    Jul 6, 2004
  4. David C. Holley

    Getting a ASP file name via VBScript

    David C. Holley, May 4, 2004, in forum: ASP General
    Replies:
    2
    Views:
    118
    David Holley
    May 4, 2004
  5. GTN170777

    asp vbscript textbox paste from word problem

    GTN170777, Oct 9, 2008, in forum: ASP General
    Replies:
    5
    Views:
    286
    B@DJJ
    Oct 17, 2008
Loading...

Share This Page