Hi,

First of all am new 2 .net concepts.

I want to retrieve the image details from the database and to display it in the screen.
eg:
1. I have stored the img details as

<asp:Image ID="Image1" ImageUrl="imgs/Titanic.bmp" style="width: 88px; height: 64px"  runat="server"  />

inside the db.
2.i used some query to retrieve this information.
3.Then i tried to display this infrmation using response.write and other tingz ,,but notg happenz..

plz tell me me how to do this.....

Recommended Answers

All 4 Replies

To display image on your form you can use the Picturebox control and the Image class:

Image yourImage = Image.FromFile(pathOfYourImage);
            pictureBox1.Image = yourImage;

Is that what you are looking for?

and just to supplement anteka, in case you are having trouble reading it from the database

SqlCommand cmd = new SqlCommand("select imagecolumn from tablename where id = 1");
SqlDataReader dataReader = cmd.ExecuteReader();
byte[] imageBytes = (byte[]) imageReader.GetValue(0);

MemoryStream ms = new MemoryStream(imageBytes);

FileStream fs = File.OpenWrite(imagePath);
fs.Write(ms.GetBuffer(), 0, ms.Position());

//now we have it on the filesystem

The RbmBinaryImage control will help you display images directly from your database. You could bind the Image field directly to the ImageContent property, also you could specify whether you want the display to be as a thumbnail or not and provide the thumbnail size.

to get it go to http://www.ramymostafa.com/?p=187

Regards
Ramy Mostafa

Hi,

First of all am new 2 .net concepts.

I want to retrieve the image details from the database and to display it in the screen.
eg:
1. I have stored the img details as

<asp:Image ID="Image1" ImageUrl="imgs/Titanic.bmp" style="width: 88px; height: 64px"  runat="server"  />

inside the db.
2.i used some query to retrieve this information.
3.Then i tried to display this infrmation using response.write and other tingz ,,but notg happenz..

plz tell me me how to do this.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.