Rajeshbala
asked on
Retrieve binary data from database and displaying in asp.net control
Hi,
I am storing Microsoft word document as varbinary(Max) on sql server 2005 db. I want to take the binary data (contents) from the database and display on the aspx page in asp.net label or other asp.net controls.
I am able to retrieve the data as Memory Stream object and bind to response object as below. But i don't want to open this content in word doc or in a seperate browser window. I want to retrieve the data and display in a asp.net control. Can you guys give a clue how to do this?...Thanks in advance
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = FileDownloaded.Content_Typ e;
Response.BinaryWrite(FileD ownloaded. Ms.ToArray ());
Response.AddHeader("Conten t-Disposit ion", "attachment; filename=" + FileDownloaded.File_Userna me);
Response.End();
I am storing Microsoft word document as varbinary(Max) on sql server 2005 db. I want to take the binary data (contents) from the database and display on the aspx page in asp.net label or other asp.net controls.
I am able to retrieve the data as Memory Stream object and bind to response object as below. But i don't want to open this content in word doc or in a seperate browser window. I want to retrieve the data and display in a asp.net control. Can you guys give a clue how to do this?...Thanks in advance
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = FileDownloaded.Content_Typ
Response.BinaryWrite(FileD
Response.AddHeader("Conten
Response.End();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You would have to change the "Content-Disposition" to "inline;" instead of "attachment;", but that only works for PDF and some other documents. I haven't seen Word documents open within the browser itself yet.