retrieve binary data from database and display in browser

Discussion in 'ASP .Net' started by =?Utf-8?B?c2NvdHRybQ==?=, Mar 23, 2007.

  1. Hi

    I am using a SQL Server 2005 varbinary(max) to store word documents in the
    database. I can retrive the data out into a MemoryStream object ok but I want
    to be able to use this to display the file in a web browser from an asp.net
    page. I found quite a lot of articles like this
    http://support.microsoft.com/kb/306654 that tell you do do it from a file on
    a hard disk but not directly from a stream object, any ideas. I would rather
    not have to create a file on the hard disk first

    Thanks
    --
    Scott
    =?Utf-8?B?c2NvdHRybQ==?=, Mar 23, 2007
    #1
    1. Advertising

  2. Manged to figure this one out, used the WriteTo method of the MemoryStream to
    write to the Response.OutputStream
    --
    Scott


    "scottrm" wrote:

    > Hi
    >
    > I am using a SQL Server 2005 varbinary(max) to store word documents in the
    > database. I can retrive the data out into a MemoryStream object ok but I want
    > to be able to use this to display the file in a web browser from an asp.net
    > page. I found quite a lot of articles like this
    > http://support.microsoft.com/kb/306654 that tell you do do it from a file on
    > a hard disk but not directly from a stream object, any ideas. I would rather
    > not have to create a file on the hard disk first
    >
    > Thanks
    > --
    > Scott
    =?Utf-8?B?c2NvdHRybQ==?=, Mar 23, 2007
    #2
    1. Advertising

  3. Well if you have got it into a byte array or a MemoryStream, you have the
    Word Document. However, you still need to use the Word Document object model
    to receive this Word Doc and render it as an actual Word document. You could
    try setting the Response.ContentType property to the MIME type for Word, and
    then BinaryWrite the bytes to the Response Output stream.
    Peter

    --
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short urls & more: http://ittyurl.net




    "scottrm" wrote:

    > Hi
    >
    > I am using a SQL Server 2005 varbinary(max) to store word documents in the
    > database. I can retrive the data out into a MemoryStream object ok but I want
    > to be able to use this to display the file in a web browser from an asp.net
    > page. I found quite a lot of articles like this
    > http://support.microsoft.com/kb/306654 that tell you do do it from a file on
    > a hard disk but not directly from a stream object, any ideas. I would rather
    > not have to create a file on the hard disk first
    >
    > Thanks
    > --
    > Scott
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Mar 23, 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. =?Utf-8?B?ZGF2aWQ=?=

    How to store/retrieve binary data in/from SQL server DB?

    =?Utf-8?B?ZGF2aWQ=?=, Jul 6, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    10,101
    sloan
    Jul 7, 2006
  2. crespoh

    retrieve data from 2 database

    crespoh, Jul 28, 2005, in forum: Python
    Replies:
    3
    Views:
    4,512
    Steve Holden
    Jul 28, 2005
  3. Karl
    Replies:
    3
    Views:
    5,195
    saloniSona
    Oct 7, 2009
  4. hib
    Replies:
    0
    Views:
    2,533
  5. Display Image Binary data in Web Browser

    , Jul 11, 2005, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    294
    Pete Wood
    Jul 15, 2005
Loading...

Share This Page