How to retrieve an image from a database?

liunx

Guest
Hi Guys,

I am doing a windows application using vb.net to an orgnization, and I was trying to retrieve a record of the person who logs in. The only thing I couldn't figure out is, how I would retrieve the picture of the person loging in from a table in the database. the table has the picture as an object I guess. I just don't know how to do it.

Any suggestion would be very appreciated.

thanks guysPleassssssssssssssssssssssssssssssssssse guys, I need it so urgently.

I would really appreciate if anyone would answer my 3 questions in .NET as soon as possible, Thanks a lotPlease guys, I have to do this for my job and I have been spending too much time on it without finding the answer. I have a deadline on July 5th for this project to be done.

I would really appreciate any helpOkay guys, no any suggestions???

I was able to get this thing to work, but in a tricky way. It is not the ideal way I guess. What I did is, I saved the name of the pictures or images in the database instead. And, I added in my vb.net application the directory of these pictures or files, which I put in a folder called "Pictures". So in the database, I have for example:
firstname, lastname, imageName. One example of image name is: pic1.jpg. So when the datagrid loads, I used the System.----.FromFile("directory" & datagrid(counter, mageNameFieldNumber) method to get the pic, and then assign it to some special picture box.

I am kind of in hurry, if you didn't understand what I am saying, please ask me. And Please if anyone has a better way of ddoing this, share it with us.

I do want to save the pictures in the same table in the database, not in a different folder, as I did.
ThanksYou need to create a page to show images, which will do a db lookup for the image data corresponding to the value of a querystring parameter. Clear out the Response; set the headers for the page; write the binary image data retrieved from the db as the page output.

Say the image display page is named EmpPic.aspx
Say that the db contains the pic data with emp_id as the pk
On a page you want the image for employee 123 to appear on, the href for the image would be EmpPic.aspx?emp_id=123

If you want a solution to be able to target an assortment of tables/databases/etc., you can use additional parameters in the querystring.

If one wanted to, and threw in the extra work, multiple images could be merged into a single image. However, the simplest solution will only deal with a single image returned from the query.
 
Back
Top