Display Images on Page from Database
-
Hi all, I googled a lot and found that to display images from database we need to fetch it from DB and Convert it to Byte[] and then pass it to Response.BinaryWrite() method. But this is not working for me. Can anyone please help me wid this?
Thanks & Regards, Pramod "Everyone is a genius at least once a year"
-
Hi all, I googled a lot and found that to display images from database we need to fetch it from DB and Convert it to Byte[] and then pass it to Response.BinaryWrite() method. But this is not working for me. Can anyone please help me wid this?
Thanks & Regards, Pramod "Everyone is a genius at least once a year"
check the link http://www.aspsnippets.com/post/Display-Images-from-Database-using-ASPNet.aspx[^]
Regards Aman Bhullar www.arlivesupport.com[^]
-
Hi all, I googled a lot and found that to display images from database we need to fetch it from DB and Convert it to Byte[] and then pass it to Response.BinaryWrite() method. But this is not working for me. Can anyone please help me wid this?
Thanks & Regards, Pramod "Everyone is a genius at least once a year"
-
Hi all, I googled a lot and found that to display images from database we need to fetch it from DB and Convert it to Byte[] and then pass it to Response.BinaryWrite() method. But this is not working for me. Can anyone please help me wid this?
Thanks & Regards, Pramod "Everyone is a genius at least once a year"
You need to create the image from byte array. use a temporary folder to create the image.
byte[] image = GetImageDataFromDatabase();
string imagepath = Path.Combine(Path.Combine(Request.PhysicalApplicationPath,"tempImages"), "imagename.jpg");
using (FileStream ofstream = new FileStream(imagepath, FileMode.Create))
{
ofstream.Write(image, 0, image.Length);
ofstream.Close();
}
imgobj.src= "tempImages/imagename.jpg";This will work. :rose:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.