retrieve binary data from database and display in browser

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Manged to figure this one out, used the WriteTo method of the MemoryStream to
write to the Response.OutputStream
 
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
 
Back
Top