.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

Writing image binary data to the Response

Posted By:      Posted Date: September 21, 2010    Points: 0   Category :ASP.Net

Hi there,

I've created 2 web user controls. A = User control that displays an image, and B is the user control that hosts A. I'm trying to stream an array of bytes to A, but it seems like the Response.BinaryWrite method completely overwrites any heirachial controls (I can't see any of B's other controls besides the image).

How do I get A to just display the image from the byte stream? It doesn't come from a database, it's an image I created on the fly.

A's code:

        public void UpdateImage(byte[] imgbytes)
            Response.ContentType = "image/jpg";


View Complete Post

More Related Resource Links

Binary Data Not Writing to Database


I have an ASP.NET app that writes binary data to a SQL database.  It worked fine using SQL Express, but does not ever write the data using SQL Server 2008 R2.  SQL Profiler shows the binary data in the UPDATE query, but nothing happens... no errors, no data saved.  Does anyone know what I'm missing?  Other data types work fine.

My data type is VarBinary(MAX)...


Binary Data Not Writing to Database

This may be more of a dev question, but I have an ASP.NET app that saves binary data to a SQL database.  It worked fine to a SQL Express 2008 database, but does not work on a SQL Server 2008 R2 Standard.  SQL Profiler shows the binary data in the UPDATE query, but nothing is ever actually written to the database.  I cannot find any errors either.  I have no problems writing other types of data.  Any ideas?

Binary Data Problem....save and retrive image data from sql database


hello friends...please help me to solve this problem....

i have created crud (create, retive, update and delete)form and it's running... here i want to add images for each record(sql database)....

i'm using image datatype in sql table for picture.....

Q 1: how to save and retrive binary data(image) from sql table in asp.net form using vb coding?

Q2: can i create sql table which store binary(image url) data direct?

thank you

How to insert Binary Image data from XML To Excel using XSLT


Hi All,

I had created a XSLT which converts the XML file generated from the system to the excel format. The XSLT has the styles required for this transformation.

Now i am told to insert image in one of the excel columns using XSLT. The image is in binary code format in the XML file.

Tried to google but could not found the syntaxes for this. Let me know if anyone has done the image embedding in excel using XSLT.


ASP.Net Create physical image from binary data in Sybase


I want to extract an image from a third party Sybase table which has binary data in it.

To store images they use the following query:

SELECT xp_write_file('C:\photo-1.gz', col_name) FROM tbl_name

What I am trying to do is convert the binary data stored to a actual physical file using .Net

Any help would be appreciated.

Help ~~ How to Update Binary Image on Formview

Hi All ~~ I'm confused, Can i have some help please... Thanks
Database: Books
uid dataType uniqueidentifier
Cover dataType image 
aspx :
 <asp:FormView ID="FormView1" runat="server" BackColor="LightGoldenrodYellow"   BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataKeyNames="uid"     DataSourceID="SqlDataSource1" ForeColor="Black" Width="525px">
         <table class="table_width">
                 <td class="imageWidth">
                     <asp:Image ID="Image1" runat="server" Height="245px" 
                                       ImageUrl='<%# IIF(Eval("Cover") Is DbNull.Value, "~/Styles/Global/CFZ-No-Images.png", Eval("uid", "~/ImageServices.ashx?BooksID={0}")) %>' Width="180px" />

Writing Data to database with jQuery Forms, ASMX Webservice, & JSON - help!



Can someone point me in the right direction on how to submit data from a jQuery form to a ASMX webservice? I have gotten everything on the form ready to be submitted to the database and now I am stuck on how to send it over using $.ajax(). Everything I have read tells me how to get data from a webservice and display it with jQuery, but not the other direction nor how to access the json data within the within the webservice service(similar to a Request.Form approach with ASP.NET forms).

In other words: 

1. What do I need to do to my webservice to make sure it can receive data from the jQuery form. 

2. What do I need to do in jQuery to receive an acknowledgement the save on the server side was successful. 

I can explain more if need be, but if there is a comprehensive tutorial on not only reading, but also WRITING data with jQuery, JSON, etc. I would love to get pointed in that direction. 

Store Null Data In image datatype in sql server 2005



i wanted to store image in sqlserver database image field and i did. But now in some cases i want to store null value in that image field please let me know how to do this using file uploader.please give complete sample code.


Create excel file from Binary data on SqlServer



My requirement is that i upload an excel file then i need to validate that data.


1. Uploading file using using upload control saving binary in SqlServer

2. Then i am creating file from binary data  on Sql Server using below command and then using OPENROWSET to dump data to Sql table

3. Then reading Sql Table row wise and validating data.


Alter Procedure spUploadExcelFile
  @PKID int,
  @BatchID int


	Declare @VarBin varbinary(max)
	Declare @FileName varchar(100)
	DECLARE @sql nvarchar(MAX)
                DECLARE @errMsg nvarchar(MAX)
	DECLARE @ObjectReturn INT
	DECLARE @ErrorSource VARCHAR(255)
	DECLARE @ErrorDesc VARCHAR(255)
	DECLARE @ObjectToken INT

	Select @VarBin  = Content , @FileName = [FileName] from MultilangBinaryData Where PKID = @PKID
	SET @FileName = 'C:\'  + @FileName
	EXEC sp_OACreate 'ADODB.Stream' @ObjectToken OUTPUT
	EXEC sp_OASetProperty @ObjectToken, 'Type', 1
	EXEC sp_OAMethod @ObjectToken, 'Open'
	EXEC sp_OAMethod @ObjectToken, 'Write', NULL, @VarBin
	EXEC sp_OAMethod @ObjectToken, 'SaveToFile', NULL, @FileName, 2
	EXEC sp_OAMethod @ObjectToken, 'Close'
	EXEC sp_OADestroy @ObjectToken  
	SET @sql = 'INSERT INTO dbo.UserBulkData SELECT 0,NULL,'+ @BatchI

Problem with passing an Image as binary through web service



I have a web service that is accessed by a windows forms application and receives updates like facility name, address, image etc. Everything works fine except the image data is not being passed to the windows app. I am saving the images in database on both sides, so when I pull it from the server I use the following code

if (!reader.IsDBNull(floorPlanOrdinal))

facility.FloorPlan = (byte[])reader["FloorPlan"];

I can see the facility.FloorPlan Dimentions as 103840 when I debug this method which means that the data is pulled from the database fine.

On the forms side though the dimentions become 0, all other values pass fine except this. Here is the facility property in the web service on server side.

using System;

using System

Writing Bitmap to Response.OutputStream - Generic Error Occured in GDI+



This is what I'm trying to do when I get the error on the server (it works on my local machine):

System.Drawing.Image image = System.Drawing.Image.FromFile(filepath);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(image); 

Response.ContentType = "image/bmp";
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Bmp);

I don't think it can be a permissions problem because this works on the server:

System.Drawing.Image image = System.Drawing.Image.FromFile(filepath);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(image);

Response.ContentType = "image/jpeg";
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);

So how do I get this to work for a bitmap?


Writing the windows forms data to an HTML file

I have a windows forms application ready now i need to transfer data from the windows forms to the web and to do this i need to write an HTML file that contains the form data, i mean the data contained in the form should be written to an HTML file to be submitted and this HTML file should be generated on the local PC. I have the code for the HTML file but how can i write this HTML file with the data values contained in my windows forms. Please give your suggestions. Best Regards, Syed

How to store binary data as nvarchar(max)?

I’m trying to store a blob of binary data as nvarchar(max) and it gets truncated after just a few bytes. I wonder why and how can I prevent it. I don’t use varbinary(max) because I’m trying to keep existing DB schema intact. Current DB contains a huge chunks of text in nvarchar(max) column and I’m trying to compress (zip) this text and store it back to the same field to reduce DB size.   DB is accessed using Sync Framework (and Entity Framework) on the client side, so actual DB engine is SQL Server Compact 3.5 SP2   Thank you! KonstantinThank you! Konstantin

ssis sql 2000 image to 2008 varbinary Failed to retrieve long data for column

Hi, I have a task that to migrate the image type column from sql 2000 to varbinary type in sql 2008. The source column having 3812353 max datalength size for the column. The package always failed with following error message. [OLE DB Source [13177]] Error: Failed to retrieve long data for column "attch_file_content_t". [OLE DB Source [13177]] Error: There was an error with output column "attch_file_content_t" (13209) on output "OLE DB Source Output" (13187). The column status returned was: "DBSTATUS_UNAVAILABLE". [OLE DB Source [13177]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "output column "attch_file_content_t" (13209)" failed because error code 0xC0209071 occurred, and the error row disposition on "output column "attch_file_content_t" (13209)" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure. Meng Chew

Generating for each data in Database new Image

Hello everybody! I have the next problem. I have in Database about 100 rows with X and Y coordinates. I have the one image -> "Car.png" How can I in one statement show all 100 cars in my Wpf Application ? ( generate for about 100 Image objects ). Best Regards, Oleg
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend