Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   retrieve binary data from database and display in browser (http://www.velocityreviews.com/forums/t486612-retrieve-binary-data-from-database-and-display-in-browser.html)

=?Utf-8?B?c2NvdHRybQ==?= 03-23-2007 03:26 PM

retrieve binary data from database and display in browser
 
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==?= 03-23-2007 05:23 PM

RE: retrieve binary data from database and display in browser
 
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?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?= 03-23-2007 05:25 PM

RE: retrieve binary data from database and display in browser
 
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



All times are GMT. The time now is 02:54 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.