CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2009
    Posts
    177

    VB.NEt web display image

    I has the following code in my vb.net:

    Code:
     Dim sql2 As String = " SELECT * FROM Etiqa_Image_Details where TransmissionID='" & Request("id") & "' "
                    With objDB.OpenDataReader(sql2)
                        While .Read()
    
                            If .Item("ImageType") = "Invoice" Then
                                imgInv.ImageUrl = .Item("ImagePath")
                                Session.Item("InvImage") = .Item("ImageID")
    
                                lbl.Text = "<img src=""" + .Item("ImagePath") + """ />"
    
                            End If
    
                            If .Item("ImageType") = "Payment" Then
                                imgPay.ImageUrl = .Item("ImagePath")
                                Session.Item("PayImage") = .Item("ImageID")
                                Response.ContentType = (.Item("ImagePath"))
                                Response.BinaryWrite(.Item("ImagePath"))
                            End If
    
                        End While
                    End With
    However,i get this error while retrieving the image path(Varchar in sql server 2000) and display the image on the web.

    Unable to cast object of type 'System.String' to type 'System.Byte[]'.


    Anyone help??

  2. #2
    Join Date
    Jul 2009
    Location
    Kuwait
    Posts
    170

    Re: VB.NEt web display image

    try
    Code:
       imgInv.ImageUrl=Image.FromFile("ImagePath")

  3. #3
    Join Date
    Jan 2009
    Posts
    177

    Re: VB.NEt web display image

    Hi, I am not able to find .FromFile method from Vb.net web application...

  4. #4
    Join Date
    Jan 2009
    Posts
    177

    Re: VB.NEt web display image

    I get this error:

    Value of type 'System.Drawing.Image' cannot be converted to 'String'.

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB.NEt web display image

    Take a look at this link
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured