Skip to Content
avatar image
Former Member

Unable to load image from database OR path unto a crystal report

Greetings, I have spent many days attempting to show an image on my crystal report in MVC C# and I have come to the conclusion that that might not be working.

I first attempted to load the image from my database.

This is what I did, and please point out if i'm doing something wrong.

First, I added a logo via insert picture then...

I saved an image as varbinary(max) in a mssql database(so it looks something like this 0x479463839). Then I selected the image, into a data table in C#, changed the data type to system.byte[]. I then created a report based on that data table. Then i drag the image column to the report and it comes up as a blob but when I run the report..nothing shows and I get a CrystalImageHandler Error.

To solve this I added the ignore route to the route

and added the lines below to the webConfg httphandler and handler.

<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>

<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>

<code>routes.IgnoreRoute("{*allaspx}",new{ allaspx =@".*(CrystalImageHandler).*"});

Upon doing that, When I ran the report again, the logo image showed up, however the image in my database field still did not show up.

What else I tried

I then attempted to display the image via the path, to accomplish that, I again stored my path in my database via code. Then I added an image (I added a picture with a dummy image and also added a paint box) > Right click>Graphic location and set the location to the database field with the path to the image. However, the image is not display, the same picture is displayed.

I also downloaded and followed this program EXACTLY and it still doesn't work.

http://www.c-sharpcorner.com/uploadfile/4d9083/store-and-retrieve-image-on-crystal-report-from-sql-database/

I would appreciate if anyone could point out where I went wrong and help me correct it or quickly test out a project to verify is "Graphic Location" works. Cause changing my graphic location has no effect on the image.

Regards

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Apr 26, 2017 at 04:02 PM

    If it doesn't work in CR Designer it's not going to work in your app.

    In CRD drop any image onto the report.

    Now right click on the image and select Format Editor. Click on the Picture tab and lower down you will see Graphic location:

    Click the X-2 button and drop the field from your DB that has the image saved in it.

    Or if the images are saved on a file share then the DB field must hold the path to the image you want to use in which case do the same above only use the DB field that holds the path into the X-2 formula.

    Now for a web app IIS Must have access to the file share with full read/write permissions. If using the database field with the image then nothing needs to be done.

    Now go into the CR 13 viewer folder:

    C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13

    And DELETE all files that do not have a .js extension, leave the folders there of course and do not use the CrystalImageHandler.ASPX. It's old and not required/supported.

    I don't suggest you follow that link, he made it much more difficult than it has to be...

    Don

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 25, 2017 at 10:40 PM

    Hi Kem,

    I added CR Design tag also so the report design people see this post.

    First thing to do is test it in CR Designer, if it not working in CRD it's not going to work in your WEB app.

    Not sure why you are changing the data type, CR should simply read it from the database as an image file.

    Don

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi, Thank you for the reply and the tag. This I believe was a last ditch effort.

      It doesn't work In CRDesign and as I said it gives the CrystalImageHandler error even if I have fixed it in the webconfig and ignore the routes.

      Do you have like a small program where this is working for you? or even Graphic Location?

  • Apr 27, 2017 at 09:42 PM

    When it's published I'll be putting together a whats new article that will be available on the download page.

    Until DEV finishes the QA'ing I can't say what will or will not be in the release.

    Don

    Add comment
    10|10000 characters needed characters exceeded

  • May 08, 2017 at 10:01 PM

    Now available from the same link above:

    https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

    No direct support on this forum.

    Don

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi thank you,
      What exactly am I to get from the link? I am now using visual studio 19 and same error.

  • May 09, 2017 at 12:59 PM

    SP 20 is now there

    Add comment
    10|10000 characters needed characters exceeded