By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 1,005 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

retrieve and display picture from a sql server

P: 4
Hi Guys!

I need help to retrieve a picture stored in a sql server DB.
In the upload process I have converted an image to Binary Data, but I have problems converting it back to a .jpg image... and display it in a form as a picture.

I'm working with asp.net c# visual studio 2010

Please help me!
Thanks!
Apr 1 '12 #1
Share this Question
Share on Google+
3 Replies


PsychoCoder
Expert Mod 100+
P: 465
Show us the code you're using to retrieve your image and display it and someone will help you find a solution to your problem.
Apr 1 '12 #2

P: 4
thanks man!, but I will just save the picture as a picture inside a folder, according to what you had recommended in this other thread.
Thanks :)
Apr 11 '12 #3

Frinavale
Expert Mod 5K+
P: 9,731
It's really not that hard to retrieve it from a database.

You would need a column in a table that is a blob/image/something-that-can-hold-bytes (depending on the database that you're using). In your case the column would be an Image type since you're using Microsoft's Sql Server

When you save the image into the database, you would read the bytes in the image into memory (a byte array) and then save that into the column in your database.

When you retrieve the image, you will have to grab the byte array from the column and convert it into the image type of your choice. The image type that you create really all depends on the type of application you're developing...in the case of a web application, you would just write it to the response.output stream and change the headers to indicate to the browser that you are sending an image (as apposed to HTML that is usually sent).

-Frinny
Apr 11 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.