I am using SQL Database,
In my example of my webpage, i got FileUpload & Image & Button Controls.
i wanna to know any tutorials or tricks from code behind that able to
upload the image file into my sql database and how to display the image in my Image controls?
P/S: For profile picture purpose

Edited by gahhon

3 Years
Discussion Span
Last Post by gahhon

I think you may want to take this and resolve it in parts. For example, first clarify if you are planning to save the image in the database, or on the file system and the link in the database?

I've looked through my documentation and found a bookmark that I used quite a bit of time ago. I think it covers pretty much what you are asking for. take a look.

Save and Retrieve Images from the Database

Edited by JorgeM


now i am able to upload and display already.
But how can i self upload a image to database?

Image img = new Image();
img.ImageUrl = "~/images/samples.png";

from code behind, how to insert to database?

        protected void uploadImage()
            string strPhoto = AppDomain.CurrentDomain.BaseDirectory + "/images/Blank.png";
            FileStream fsPhoto = new FileStream(strPhoto, FileMode.Open, FileAccess.Read);
            Byte[] imageByte = new Byte[fsPhoto.Length];
            fsPhoto.Read(imageByte, 0, Convert.ToInt32(fsPhoto.Length));

            // SQL CODE

Problem solved. Thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.