Displaying the image from the Sql Hi, I am trying to display image on the page stored in the SQL DB. Image is store in the <BinaryData> format in the DB. I am display in the DataGrid its working fine, problem with page.
SqlCommand Cmd = new SqlCommand(Query, myconnection);
SqlDataReader dr = Cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
lblProdName.Text = Product;
lblProdDesc.Text = dr[0].ToString();
lblPrice.Text = dr[3].ToString();
//dr\[5\] image
byte\[\] Photo = (byte\[\])dr\[5\];
Response.ContentType = "image/jpeg";
Response.OutputStream.Write(Photo, 0, Photo.Length);
}
dr.Close();
only image is displayed on the page without any other content , if I comment lines
// Response.ContentType = "image/jpeg";
// Response.OutputStream.Write(Photo, 0, Photo.Length);
All the contents are displayed except the image. what is the proper way to display the image on the page using SQL ?? Please help me with this. Thanking you, Naveen.