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. Crystal report dynamically load an image on report document

Crystal report dynamically load an image on report document

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

    Hi I have a crystal report invoicing application that generates invoices. i have a logo on that invoice. I wanted to change the image based on if some condition met on code behind. Can anyone please shed some light on how to do this. This is what i am doing currently. private void CreateImageDataTableAndWriteSchema() { this.DsImages = new DataSet(); DataTable ImageTable = new DataTable("Images"); ImageTable.Columns.Add(new DataColumn("path", typeof(string))); ImageTable.Columns.Add(new DataColumn("image", typeof(System.Byte[]))); this.DsImages.Tables.Add(ImageTable); //this.DsImages.WriteXmlSchema(@"c:\myinvoices\ImagesSchema.xsd"); } as you can see from commented code that, I am creating an xsd dataset and I have added that dataset to the database fields. Then i have place image field from that table on to the report document. Then below i am loading an image file in that dataset/datatable. then i am loading image in to the dataset created above private void LoadLogoImage() { FileStream FilStr = new FileStream("C:\\mystuff\\Images\\my_logo.jpg", FileMode.Open); BinaryReader BinRed = new BinaryReader(FilStr); DataRow dr = this.DsImages.Tables["Images"].NewRow(); dr["path"] = "C:\\mystuff\\Images\\my_logo.jpg"; dr["image"] = BinRed.ReadBytes((int)BinRed.BaseStream.Length); this.DsImages.Tables["Images"].Rows.Add(dr); FilStr.Close(); BinRed.Close(); } Lastly, i am setting the datasource of the report document as following reportDocument.Subreports[SummaryDocument].Database.Tables["Images"].SetDataSource(DsImages.Tables["Images"]); I get error, invalid index when i try to execute this line. As stated above, i am trying to set the Images table datasource to the dataset we just poppulated with image path and byte data. fyi: i have a master report which holds 8 subreport. The SummaryDocument listed above is one of those subreport.

    Thanks Needy

    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