Can someone help me??

How to retrive image from MySQL(not MS_SQL) and show into my <asp:Image> control using c#

Lets said my table on have a field as following:

"SELECT pic FROM image"

Thanks in advance !!

Recommended Answers

All 4 Replies

I have the problem too. I searched but not found any solution. plz guid me
(^_^)

You should save the image path in the table. Then retrieve from it.

get Byte Array from DB then convert it into image and save it into some folder on serverside then use the URL of that image to represent it
eg:-
imageSample.imageURL=~URLofYourImage;
CODE:-

public  void byteArrayToImage(byte[] byteArrayIn)
    {
        try
        {
            MemoryStream ms = new MemoryStream(byteArrayIn);
            System.Drawing.Image imgPhoto =  System.Drawing.Image.FromStream(ms);
            imgPhoto.Save(Server.MapPath("temp.jpg"));
            imgEmployee.ImageUrl = "~/Employee/temp.jpg";
        }
        catch (Exception ex)
        {
            imgEmployee.ImageUrl = "~/Admin/emp1.jpg";
            ExceptionLogger.PublishError(ex);
        }
    }
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.