473,394 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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
Mar 23 '07 #1
2 3151
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
Mar 23 '07 #2
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
Mar 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Blaktyger | last post by:
How can this be done? Images are stored in a LONGBLOB field. When I try to display them, it prints out the binary data as it is... Thank you
3
by: | last post by:
Hi, I have a SQL Server database table where one of the columns is of type Image. The problem occurs when I try to retrieve images from the table. I'm using the following C# code: ...
2
by: Adam | last post by:
I have extensively searched for a solution. Below is my code that is contained in an aspx. When my browser hits this aspx, I just get the standard broken image picture. I know the data is the...
15
by: mleaver | last post by:
I want to open a second window and display a binary image that is returned from a java program via XMLRPC. The data returned is a binary encoded base64 png file. If I write the data out to a file...
4
by: Pedro Leite | last post by:
Good Afternoon. the code below is properly retreiving binary data from a database and saving it. but instead of saving at client machine is saving at the server machine. what is wrong with my...
13
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end...
3
by: Alfred | last post by:
I want to post text field data from these HTML TEXTAREA tags to a PostgreSQL database and have it reappear back on another page exactly as I had typed it. Over the years I have done this but only...
1
by: ahujasatna | last post by:
Hi all!! i am working on C#, ASP.Net with Sql server2000 and i am facing a problem, my Question is: "How to insert and retrieve images to/from Sqlserver2000 Database" I created a table...
14
by: Brad | last post by:
I have a .net 2.0 web application project that creates a pdf file, saves the pdf to disk (crystal reports does this part), and then my code reads the pdf file and writes it to the httpresponse ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.