473,804 Members | 2,962 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3189
Manged to figure this one out, used the WriteTo method of the MemoryStream to
write to the Response.Output Stream
--
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.Conten tType 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
5047
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
2408
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: SqlDataReader dr = sqlCommand.ExecuteReader();
2
5236
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 database is correct because I have seen another employee retrieve it using Crystal Reports. Can someone please tell me what I am doing wrong and offer a suggestion to make this work? (This code does not generate errors, I just can't the image to...
15
9815
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 on my server, I can display it using the following javascript: var windowHandle = window.open('about:blank','windowName','width=250,height=250'); windowHandle.document.write('<img name="myImage" src="images/test.png">');
4
6726
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 code ?? thank you Pedro Leite From Portugal ------------------------------------
13
3439
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 of the form which is submit and cancel. After i have clicked submit, the information is stored directly into my corresponding database table. My problem here is i need to retrieve back the information submitted to display all the data that the...
3
5070
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 did it with simple text. This time around, I want to handle much more complex text. I need to preserve some kinds of features. (Yes, I have turned off magic quotes.) - Need to strip diacritics. I learned I could use htmlentities to catch...
1
13273
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 in database there are only two Columns:
14
9511
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 The web app works great on win2003 and xp and the end result is a pdf file is displayed in the browser. When I run the same code on Vista, the browser displays the message "Internet Explorer cannot display the web page". If I open the same...
0
10561
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.