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. C#
  4. Error Cannot implicitly convert type 'byte' to 'CrystalDecisions.CrystalReports.Engine.BlobFieldObject'

Error Cannot implicitly convert type 'byte' to 'CrystalDecisions.CrystalReports.Engine.BlobFieldObject'

Scheduled Pinned Locked Moved C#
databasehelptutorial
3 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.
  • K Offline
    K Offline
    KIDYA
    wrote on last edited by
    #1

    Hello Experts!! I got above error when displaying image in crystal report..... I am assigning root as Blobfield object and assigning to database field.but it gives error. My code is: while (dr.Read()) { CrystalDecisions.CrystalReports.Engine.BlobFieldObject root; root = (CrystalDecisions.CrystalReports.Engine.BlobFieldObject)objRpt.ReportDefinition.ReportObjects["Picture2"]; object s = dr["Picture"]; Byte s2 = Convert.ToByte(s); root=(Byte)s2; } i dont knw how to bind dr with object.Suggest me method.......

    K 1 Reply Last reply
    0
    • K KIDYA

      Hello Experts!! I got above error when displaying image in crystal report..... I am assigning root as Blobfield object and assigning to database field.but it gives error. My code is: while (dr.Read()) { CrystalDecisions.CrystalReports.Engine.BlobFieldObject root; root = (CrystalDecisions.CrystalReports.Engine.BlobFieldObject)objRpt.ReportDefinition.ReportObjects["Picture2"]; object s = dr["Picture"]; Byte s2 = Convert.ToByte(s); root=(Byte)s2; } i dont knw how to bind dr with object.Suggest me method.......

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

      Are you using a dataset? If you are using a dataset specify the datatype of the picture column to System.Byte[]. Then from the database set the value to that column as below : DataColumn mycolumn = new DataColumn ("Picture"); mycolumn.DataType = typeof(System.Byte[]); mysdset.Tables[0].Columns.Add(mycolumn); mysdset.Tables[0].Rows[0]["Picture"] = GetImageData(Server.MapPath("~/ABC.Jpg")); byte[] GetImageData(string fileName ) { //Method to load an image from disk and return it as a bytestream System.IO.FileStream fs = new System.IO.FileStream(fileName,System.IO.FileMode.Open, System.IO.FileAccess.Read); System.IO.BinaryReader br = new System.IO.BinaryReader(fs); return (br.ReadBytes(Convert.ToInt32(br.BaseStream.Length))); } Hope this helps you

      K 1 Reply Last reply
      0
      • K Kanniah

        Are you using a dataset? If you are using a dataset specify the datatype of the picture column to System.Byte[]. Then from the database set the value to that column as below : DataColumn mycolumn = new DataColumn ("Picture"); mycolumn.DataType = typeof(System.Byte[]); mysdset.Tables[0].Columns.Add(mycolumn); mysdset.Tables[0].Rows[0]["Picture"] = GetImageData(Server.MapPath("~/ABC.Jpg")); byte[] GetImageData(string fileName ) { //Method to load an image from disk and return it as a bytestream System.IO.FileStream fs = new System.IO.FileStream(fileName,System.IO.FileMode.Open, System.IO.FileAccess.Read); System.IO.BinaryReader br = new System.IO.BinaryReader(fs); return (br.ReadBytes(Convert.ToInt32(br.BaseStream.Length))); } Hope this helps you

        K Offline
        K Offline
        KIDYA
        wrote on last edited by
        #3

        Thanx for healthy reply....i used your code but it gives error at following point as " Cannot find table 0" mysdset.Tables[0].Columns.Add(mycolumn);

        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