Wednesday, April 15, 2009

Upload images onto SQL Server using ASP.NET webpage

Uploading images is one of the most frequently required features of a blog/website.

This program explains you how to upload images onto a SQL Server 2008 db using VS 2008 with code written in C#.

Open SQL Server 2005/2008 instance, select a db and create a table (Image_Gallery) with following attributes.


1)Open a new website, In solution explorer of VS 2008/2005 add a new aspx page.

2) Add an FileUpload control onto the webpage.

3) Add a button to the asp page and name it to "Upload"

3) Double click on it to go to the logic.

4) add the following code in the event handler of the "Upload" button

Now, Save and Run the application. Its done.