Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Dynamically Loading Image in Crystal Report

Dynamically Loading Image in Crystal Report

Scheduled Pinned Locked Moved Visual Basic
helpdatabasedebuggingannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Ovais Memon
    wrote on last edited by
    #1

    I have a field of Image path on database and I need to display the image of student in crystal report. I am using VS2005 with crystal report version 9. I have added the unbound column named "Image" of type system.byte in Data Set and at the load event, I have write the following code. Dim da As New DataSet1TableAdapters.AdmissionFormTableAdapter Dim dt As New DataSet1.AdmissionFormDataTable da.FillByStudentID(dt, _studentID) Dim dtCopy As New DataTable ''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'Code Start to Set Image ''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim blankFile As String = "C:\Program Files\blank.JPG" If dt.Rows(0).Item("ImagePath").ToString <> "" Then Dim s As String = dt.Rows(0).Item("ImagePath").ToString If FileIO.FileSystem.FileExists(s) Then Dim fs As FileStream = New FileStream(s, FileMode.Open, FileAccess.Read) Dim image(fs.Length) As Byte fs.Read(image, 0, Convert.ToInt32(fs.Length)) dt.Rows(0).Item("Image") = image fs.Close() Else Dim fs As FileStream = New FileStream(blankFile, FileMode.Open, FileAccess.Read) Dim image(fs.Length) As Byte fs.Read(image, 0, Convert.ToInt32(fs.Length)) dt.Rows(0).Item("Image") = image fs.Close() End If Else Dim fs As FileStream = New FileStream(blankFile, FileMode.Open, FileAccess.Read) Dim image(fs.Length) As Byte fs.Read(image, 0, Convert.ToInt32(fs.Length)) dt.Rows(0).Item("Image") = image fs.Close() End If ''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'Code End to Set Image ''''''''''''''''''''''''''''''''''''''''''''''''''''''' dtCopy = dt.Copy Me.rptAdmissionForm1.SetDataSource(dtCopy) Me.rptAdmissionForm1.SetParameterValue("ID", _studentID) When I run the code, error comes that "unable to cast type of system.byte to system.IConvertible", although the datatype of column "Image" is system.byte, and when I debug the code, it shows the datatype of dt.Rows(0).Item("Image") = System.DBNull, Please help me out..!

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups