cancel
Showing results for 
Search instead for 
Did you mean: 

Logo image not displaying in Crystal Report Subreport C# ASP.NET MVC

0 Kudos

I am new to Crystal Reports in ASP.net MVC. I have a main report with a logo from a subreport. The subreport is a separate .rpt file that gets its data from an image saved in the database in a binary string format. This logo's datatype when checked in the xsd is String.Byte[].

However, when I run the report viewer in the web browser, no image is being displayed. Even when I click on the box of the logo in the web browser and the separate rpt file is loaded, the report is blank.

I can confirm that this specific logo saved in the DB can be displayed in the report viewer when I tried to add a column for the image in the stored procedure that is used to populate and dragged that field in my main report.

I hope someone can help me as I am stuck here for days. This is what my code looks like in the report viewer:

        report.Subreports["Logo"].ReportDefinition.ReportObjects[0].Height = 1500; //Convert.ToInt32(reportParam.CRParameters["COMPANYLOGOHEIGHT"]);
        report.Subreports["Logo"].ReportDefinition.ReportObjects[0].Width = 5250; //Convert.ToInt32(reportParam.CRParameters["COMPANYLOGOWIDTH"]);
        report.Subreports["Logo"].ReportDefinition.ReportObjects[0].Left = 13;

        report.SetDataSource(reportParam.DataSource["Table"]);
        report.Subreports["Logo"].SetDataSource(reportParam.DataSource["Logo"]);

        StatementOfHoldingsReport.ReportSource = report;

I believe I am missing something when the image is being displayed in the separate sub report. I can also confirm that the string of bytes can be found in the row of the reportParam.DataSource["Logo"].

former_member27
Community Manager
Community Manager

Hi jj_sone,

Welcome to the SAP Community! Thank you for visiting us to get answers to your questions.

Since you're asking a question here for the first time, I'd like to offer some friendly advice on how to get the most out of your community membership and experience.

First, please see https://community.sap.com/resources/questions-and-answers, as this resource page provides tips for preparing questions that draw responses from our members. Secondly, feel free to take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html as well, as that will help you when submitting questions to the community.

Finally, I recommend that you include a profile picture. By personalizing your profile, you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html.

I hope you find this advice useful, and we're happy to have you as part of SAP Community!

Regards,

Dedi

Accepted Solutions (1)

Accepted Solutions (1)

DonWilliams
Active Contributor
0 Kudos

"PS: It doesn't also show when I try to view the report in CR Designer."

This suggests you do have network or permission issues if it only works some times. Could be resource issues also.

Not sure what else to suggest, if it's off/on in CRD it's going to be an issue in the SDK because the SDK uses the same API's CR Designer uses.

Answers (5)

Answers (5)

0 Kudos

Does it work when you view the report in CR Designer?

If it doesn't work in CRD it won't work in code.

Try saving the image in a location that IIS has permission to access.

Maybe WireShark will help debug the problem:

https://social.msdn.microsoft.com/Forums/en-US/5fd774c0-615c-4346-aa70-ea54e52fb569/images-will-not-...

0 Kudos

Hi Don,

The image is not on my machine and is only saved as binary data. I tried creating a Dataset and filling it up using a stored procedure in the Database Expert (meaning I need to log in to the DB to populate). The image appeared in this way.

However, when I tried to fill the Dataset programmatically in code using a stored procedure, the image is not showing.

PS: It doesn't also show when I try to view the report in CR Designer.

0 Kudos

Version is fine, CR loads the Assembly Framework version, not the dll version.

It could be a API order issue, what happens if you comment out all of the Image and DB code and just preview the report, let it prompt for DB connection info?

If your data source gets is data from an Stored Procedure why not connect to the SP rather than an XML file?

0 Kudos

You mean to connect the subreport to the SP rather than the XSD? Sorry, I don't understand, which XML file?

I will also try to comment out all the image and DB code and get back to you on the result.

0 Kudos

Hi Don, I still don't get the image when I let the DB prompt. Do you have other ideas? Can you expound on what you mentioned about connecting the SP rather than an XML file?

Thank you!

0 Kudos

Yes update the Report in either VS or use CR 2016 or Cr 2020 to update it.

Open the report and Verify database should fix it but you may need to use Set Database Location...

0 Kudos

I did this but the image still doesn't load. All CrystalDecisions references in my Web.config uses CrystalDecisions.Web, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304. Should this also be changed? If yes, what should be the correct version? And if there are other things I should change, please let me know.

Thank you Don, for helping me so far.

0 Kudos

Hello,

Ah, thank you for checking. You are using SP 31, it had a lot of image and viewer related issues.

Can you download and upgrade your app to use SP 32, it fixed a lot of them:

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

Thank you

Don

0 Kudos

Hi Don,

I installed the SP 32, however, I am getting Failed to load database information error. According to this page, the cause is old Crystal Report has not been updated for use in the current version of Crystal. With this, should I do something on the existing CR?

This is the stack trace and I didn't modify anything on the code. Exception was happening on report.SetDataSource

[COMException (0x800002cd): Error in File temp_f9119fe1-68fa-4004-bc38-133ff2da92f1 1168_18204_{90723655-5B93-4CA9-975E-82C8ED598390}.rpt:
Failed to load database information.]
   CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.ReplaceConnection(Object oldConnection, Object newConnection, Object parameterFields, Object crDBOptionUseDefault) +0
   CrystalDecisions.CrystalReports.Engine.Table.SetDataSource(Object val, Type type) +536
   CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type) +136

[DataSourceException: Error in File temp_f9119fe1-68fa-4004-bc38-133ff2da92f1 1168_18204_{90723655-5B93-4CA9-975E-82C8ED598390}.rpt:
Failed to load database information.]
   CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e) +337
   CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type) +203
   CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataSet dataSet) +60
   CallSite.Target(Closure , CallSite , InvestorStatementOfHoldingsReport , Object ) +135
0 Kudos

Need versions you are using

0 Kudos

Hi Don,

Crystal Reports: Version 13. In my installation, it says BuildVersion=13.0.31.4010

Visual Studio: 16.11.14

Thank you!