Answered by:
Display an image from an image server via it's url

Question
-
Hello Community,
I have a form which is a "product manager". The purpose of this form is to add or update products in a database which are displayed on a ecommerce website. I would like to have the image of each product display in a "picture box" on the form as I click through each product using the form. The thumbnail images for every product is stored on an "image server" in a folder "product_images".
In the database, their is a table named "products" which has several fields for each product information, including a field to add the image url to the image server. How could I code the picture box or use the fields url to display the image associated to each record in the form (database)?
I am actually using Visual Studio 2008.
Thanks to anyone who can assist me.
Wednesday, January 28, 2009 12:28 AM
Answers
-
Use the load method of the picturebox once your have the url of the image .
PictureBox1.Load("http://SomeWebSite/images/SomeImage.jpg") - Proposed as answer by bdbodger Thursday, January 29, 2009 8:24 AM
- Marked as answer by DPSOfficer Thursday, January 29, 2009 9:24 PM
Wednesday, January 28, 2009 2:06 AM
All replies
-
Use the load method of the picturebox once your have the url of the image .
PictureBox1.Load("http://SomeWebSite/images/SomeImage.jpg") - Proposed as answer by bdbodger Thursday, January 29, 2009 8:24 AM
- Marked as answer by DPSOfficer Thursday, January 29, 2009 9:24 PM
Wednesday, January 28, 2009 2:06 AM -
Hello bdbodger,
Thank you for your response. I apologies for my limited knowledge on this. The load method looks like it would have to have the URL hard coded for a particular image. Would you know how I could automate the code in the ( ) to pull the URL from the image URL field in the database table? This would allow the pictureBox1 to display the image associated with the current record displayed and the image change as each new record is displayed.
Thanks for all your help.
Wednesday, January 28, 2009 11:14 PM -
If you can retrive the URL from the database you can pass it to the load function . I don't know anything about an image server so I can't help in that regard but if the database field has a reference to an image in a directory on a server then you should be able to pass that URL to the load function . If any function returns a path to an image then you can use that the same way . You pass the load function a string that is the path or URL to an image .
- Proposed as answer by bdbodger Thursday, January 29, 2009 8:24 AM
Wednesday, January 28, 2009 11:26 PM -
Hello bdBodger,
We found the right code to make this work. I'm posting the code so hopefully this thread will help someone else someday.
Thank you for you rapid responses.
Code:
Sub thumbnail(ByVal prod As String)PictureBox2.Load("http://www.extremesportsnutritioncenter.com/images/products/thumbnail/" + prod + ".jpg")
End Sub
Private Sub Prod_stock_codeTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Prod_stock_codeTextBox.TextChanged
Try
thumbnail(Prod_stock_codeTextBox.Text)
Catch ex As Exception
PictureBox2.Load("")
Return
End Try
End Sub
- Marked as answer by DPSOfficer Thursday, January 29, 2009 5:08 AM
- Unmarked as answer by DPSOfficer Thursday, January 29, 2009 9:24 PM
Thursday, January 29, 2009 5:08 AM -
I see glad you have it but too bad I didn't get any credit for my help :-( I see you marked your own post . I didn't even get so much as a helpful credit . Oh well if you have any more questions I guess somebody might still help you .Thursday, January 29, 2009 5:32 AM
-
I'm new with this forums, I will see if I can change that, I didn't realize that you only get credit if you are marked as such, sorry.Thursday, January 29, 2009 9:23 PM
-
Ok, I changed the "mark as answer", I truely apologies for not knowing how the rating system works. I do appriciate all your help though.Thursday, January 29, 2009 9:26 PM
-
No problem . You can also mark more than one post as the answer if more than one person has given a correct answer . So you could have left your post marked .Thursday, January 29, 2009 10:27 PM