0

My problem is to insert an image into sql server using c# and also to select that image from database.
I have following function to show image in image control, it is showing but I don't know how to save that image into database using stored procedure.

protected void uplaod_Click(object sender, EventArgs e)
    {
        if (FUP_WatermarkImage.HasFile)
        {
            System.IO.Stream fs = FUP_WatermarkImage.PostedFile.InputStream;
            System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
            Byte[] bytesPhoto = br.ReadBytes((Int32)fs.Length);
            string base64String = Convert.ToBase64String(bytesPhoto, 0, bytesPhoto.Length);
            Image1.ImageUrl = "data:image/png;base64," + base64String;
            Image1.Visible = true;

        }    

    }

What do I need to save image into database?

2
  • 2
    it is not a good idea save image into DB. Commented Jan 25, 2014 at 21:03
  • 1
    If you have another choice don't save as a byte because your db size will grow. Just save upload path as string. Commented Jan 25, 2014 at 21:49

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.