Solved

How to link image to http://

Posted on 2007-12-03
6
287 Views
Last Modified: 2013-11-26
Hi experts,

I want to display image which located in http://myimages.mysite.com onto PictureBox in VB 2005 forms.
I tried it with following codes with ERROR in line "PictureBox1 = Image.FromFile( http://myimages.mysite.com /upload/pubFilePath)"
Would you please advise me?

Thanks,
HD

    Private Sub PhotoDataGridView_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles PhotoDataGridView.CellClick
        If e.RowIndex >= 0 Then
            pubFileName = PhotoDataGridView.Rows(e.RowIndex).Cells("PhotoFileName").Value.ToString
            PictureBox1 = Image.FromFile( http://myimages.mysite.com /upload/pubFilePath) ===> ERROR
        End If
    End Sub
0
Comment
Question by:Takeoutdinner
  • 3
  • 3
6 Comments
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 20397101
Private Sub PhotoDataGridView_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles PhotoDataGridView.CellClick
        If e.RowIndex >= 0 Then
            pubFileName = PhotoDataGridView.Rows(e.RowIndex).Cells("PhotoFileName").Value.ToString
            Dim wc As New System.Net.WebClient()
            Dim ms As New IO.MemoryStream(wc.DownloadData("http://myimages.mysite.com /upload/pubFilePath"))
            PictureBox1 = Image.FromStream(ms)
        End If
    End Sub
0
 

Author Comment

by:Takeoutdinner
ID: 20397174
Hi expert,
This PictureBox1 = Image.FromStream(ms) has eroor message:
Value of Type 'System.Drawing.Image' cannot be converted to 'System.Windows.Forms.Picture'

What should I do ?

Thanks,
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 20397610
Oops.  Change it to:
PictureBox1.Image = Image.FromStream(ms)
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:Takeoutdinner
ID: 20397730
Hi expert,

When I run it, I have this error message "URI formats are not supported" at "           Dim ms As New IO.MemoryStream(wc.DownloadData("http://sunenergy.oncmc.com /upload/pubFilePath"))"

Your kid advice would be appreciated.

Thanks,

0
 
LVL 18

Accepted Solution

by:
jcoehoorn earned 50 total points
ID: 20398095
I just copy/pasted the url you were using.  Looking at it now more closely, I see two things:
1)  You have an extra space in your url.
2)  You don't specify a file name.  Did you mean to use pubFileName from above?

Try this:
IO.MemoryStream(wc.DownloadData("http://sunenergy.oncmc.com/upload/pubFilePath/" & pubFileName))
0
 

Author Comment

by:Takeoutdinner
ID: 20398190
Thanks expert!
It's working fine with this:

          Dim ms As New IO.MemoryStream(wc.DownloadData("http://sunenergy.oncmc.com/upload/" & pubFilePath))
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now