473,414 Members | 1,697 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,414 software developers and data experts.

to display image in image control from data base

How to display image in image control , which is retrieved from the data base . using c# in asp.net

regards,
FAIZAL AHMED.H
Mar 7 '08 #1
5 1847
Plater
7,872 Expert 4TB
What part are you having trouble with?
Create a Bitmap (or Image) object from the data you retreive and set it as the image for the image control.
Mar 7 '08 #2
Expand|Select|Wrap|Line Numbers
  1. MyCommand = new SqlCommand("SELECT IMAGE_DATA FROM MYTABLE WHERE ID=1", MyConnection);
  2. MyConnection.Open();
  3. MyReader = MyCommand.ExecuteReader();
  4.  
  5. if (MyReader.Read())
  6. {
  7.    byte[] m_MyImage = (byte[])MyReader["IMAGE_DATA"];
  8.    Response.BinaryWrite(m_MyImage);
  9. }
  10.  
This is how , i retrieved image from the data base , now i would like to display that image in my image control ..can you help me in converting this byte array into Image object or bit map object and bind that object into the image control .. -
Mar 10 '08 #3
use this

This will create an image object then this object can be reffered into Image Control.
Expand|Select|Wrap|Line Numbers
  1. using (MemoryStream ms = new MemoryStream(my_MyImage,0,my_MyImage.Length)) 
  2.  
  3. ms.Write(my_MyImage,0,my_MyImage.Length); 
  4.  
  5. System.Drawing.Image newImage = Image.FromStream(ms,true); 
  6.  
  7. }
  8.  
Mar 10 '08 #4
Thank you very much , now the code is working fine as per my expectation .

regards,
FAIZAL AHMED.H
Mar 10 '08 #5
Plater
7,872 Expert 4TB
I figured it was probably how to get a bitmap object from a byte[]. But someone beat me to posting about MemoryStream, hehe.
Mar 10 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Kevin Myers | last post by:
Hello, Please forgive my reposting of this note with hopefully a more relevant subject line. On an Access 2000 form under Windows 2000 I would like to use a Kodak Image Edit Control to...
12
by: Wadim Grasza | last post by:
I want to store and display (on a form or a report) multiple pictures per record in an access database. The pictures are not stored within the database. They are stored as files and the database...
3
by: Steve Montague | last post by:
I need to decode a base64 image and display it in a PictureBox control. Currently I get an "Invaild character in a Base-64 string." error, so not sure if a bad file or bad code, I have: byte...
2
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
5
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page...
10
by: Mirek Endys | last post by:
Is there a posibility to make web control, that is drawing an image to webpage without needing to save it into a file? (for example, i will save picture into db server and I want to show it...
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
2
by: CK | last post by:
Hello All, I am trying to extend the default asp:ImageButton to include an image for an enabled state and a second image for a disabled state. I currently did this by extending the ImageButton...
3
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...
0
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...
0
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...

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.