Click here to Skip to main content
15,937,127 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
Dear Friends,

I have a problem regarding saving the image into sql server 2008 database table column.

what process i have to follow in order to save the image into database as when i am uploading the image through the file uploader control in then on the click of the submit button i am trying to fetch the details of the file and converting it into the bytes format in order to store it into the DB but i am not able to get anything from it.

As my whole form is kept in an update panel so when ever a postback event occurs on some control the path in the file uploader control gets cleared and so i am not able to save the same into the file. Please let me know if there is some other way around.

Thanks & Regards

Varun Sareen
Updated 9-Dec-11 19:39pm

Share this answer
Varun Sareen 12-Dec-11 2:51am    
Hey Prakash,

Here i have saved the image in bytes into the database but when i am trying to get it from the database in order to decrypt it and display in image control, i found that the column of the image is not there in Datatable. I read from somewhere that the image can only be read from sql data reader.

Kindly throw some light on it.


Varun Sareen
Just a suggestion, use varchar as your table column then instead of converting to bytes, you just need to save the path of the image to your server.

Share this answer
Varun Sareen 6-Dec-11 2:19am    
I am not able to collect the path uploaded from the control in order to save it into the database. When ever i click on the submit button the page gets postback and the path from the Upload control gets lost :(
Varun Sareen 10-Dec-11 5:48am    
My vote for 1 not relevant to my need

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900