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. Image not loading in Crystal Report

Image not loading in Crystal Report

Scheduled Pinned Locked Moved Visual Basic
helpvisual-studiodesigndebugging
2 Posts 2 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

    Dear All, I have some problem in loading an image in crystal report. I am using VS 2005 with CR 9. I have a table adapter in which i used an unbound column "Image" of type System.Byte. And I used the following code to set image. .... Dim s As String = dt.Rows(0).Item("ImagePath").ToString 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 ................................(1) fs.Close() .... But it throws an exception at (1) [Unable to cast type of System.IConvertible to type System.Byte] I used to debug the code, and when i reached at (1), i found the datatype of dt.Rows(0).item("Image") = System.DBNull Although it is set to type System.Byte at design time in Table Adapter. Please help me out Regards, Ovais

    K 1 Reply Last reply
    0
    • O Ovais Memon

      Dear All, I have some problem in loading an image in crystal report. I am using VS 2005 with CR 9. I have a table adapter in which i used an unbound column "Image" of type System.Byte. And I used the following code to set image. .... Dim s As String = dt.Rows(0).Item("ImagePath").ToString 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 ................................(1) fs.Close() .... But it throws an exception at (1) [Unable to cast type of System.IConvertible to type System.Byte] I used to debug the code, and when i reached at (1), i found the datatype of dt.Rows(0).item("Image") = System.DBNull Although it is set to type System.Byte at design time in Table Adapter. Please help me out Regards, Ovais

      K Offline
      K Offline
      Kschuler
      wrote on last edited by
      #2

      I haven't used a Table Adapter like you are talking about, but one thought that came to me when reading this is that a System.Byte is not the same data type as your image variable. You need a Byte array. This code: Dim image(fs.Length) As Byte declares a Byte array, not a Byte. Hope this helps.

      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