Search code examples
c#visual-studio-2010crystal-reports

How to insert dynamically images in Crystal Reports


I am developing a WinForms App which can generate a report of my college students.

I am using Crystal Reports but I don't know how to retrieve student photos from the file system.

Student photos are stored on the file system and use this naming convention:

C:\Id Maker\"Clgid".jpg

Where Clgid is a value stored in a database.

As an example, my Clgid is AAAAAAA which links to my photo on the file system as C:\Id Maker\AAAAAAA.jpg

I am struggling with how I can look up the database value of Clgid and then retrieve the photo from the file system so I can display it in my Crystal Report.


Solution

  • First, add a graphic as a placeholder into your report where you want it to display. Then, right-click the graphic -> 'Format Graphic' -> 'Picture' tab -> Add a formula under 'Graphic Location' that builds your path string. Something like 'C:\Id Maker\' + {table.Clgid} + '.jpg' should work.