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