Click here to Skip to main content
15,063,889 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I am asking a common problem (and sorry for this). I got lots of example, but I am not able to fix my error. My problem is, I want to show crystal report on my web page (using visual studio 2010 - asp .Net & c#), but it is coming blank (no error occur). I noticed several article with same issue, but I fail to figure out exact problem. Please help me to find out the problem. Thanks in advance.

What I have tried:

On web.config
HTML
        <httpHandlers>
    <add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
    </httpHandlers>
<assemblies>
        <add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
        <add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
        <add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
        <add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
        <add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
        <add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
      </assemblies>
  <buildProviders>
        <add extension=".rpt" type="CrystalDecisions.Web.Compilation.RptBuildProvider, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
      </buildProviders>
    <handlers>
    <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"/>
    </handlers>


On .asp Page

ASP.NET
<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %>

    <CR:CrystalReportViewer ID="crv_Report" runat="server" Height="550px" Width="350px" AutoDataBind="True" /> 

On .cs Page
HTML
DataTable _Data = Get_Data();

ReportDocument _rpt = new ReportDocument();
_rpt.Load(Server.MapPath("CrystalReport.rpt"));
_rpt.SetParameterValue("Report_Data", "Hello! How are you?");
_rpt.SetDataSource(_Data);
crv_Report.ReportSource = _rpt;
crv_Report.DataBind();
Posted
Updated 31-Aug-18 4:15am

1 solution

The quickest way is figure out why it's not displaying is to use the debugger to step into your code.

Three possible issues:

(1) Verify the RPT file if you are pointing to the correct location.
(2) Verify DataSource that you set in your RPT. In your case the _Data. Does it have a rows returned?
(3) Verify the parameter that you passed in your RPT if it matched.

Here are a couple of tutorials I found on google on how to work with Crytal Reports in ASP.NET:

How to Create Crystal Reports in ASP.NET Webforms[^]
Create Crystal Reports Report in ASP.Net
   
Comments
Subrata.In 31-Aug-18 15:36pm
   
Thank you vary much for your reply, and also thanks for your link. It is very help full. But sorry to say that I am not able to figure out the problem.
1. Yes, report file in correct location.
2. Data Source & Data Structure are correct and also loading data properly (I used it on GridView for checking).
3. Parameter also correct.

There is no error/exception occur. I try to figure out by step by step break point, which is given below.
ReportDocument _rpt = new ReportDocument();
-> So many exception
_rpt.Load(Server.MapPath("rpt_Demo.rpt"));
-> HasRecords = '_rpt.HasRecords' threw an exception of type 'CrystalDecisions.CrystalReports.Engine.LogOnException'
_rpt.SetParameterValue("Report_Data", "Hello! How are you?");
-> Same as above
_rpt.SetDataSource(_Data);
-> HasRecords = Function evaluation timed out. And all after this
crv_Report.ReportSource = _rpt;
-> DefaultXmlExportSelection = '_rpt.DefaultXmlExportSelection' threw an exception of type 'System.NullReferenceException'

Please Note:
a) At the time of designing I use belo table/database for preparing report :
MS OLEDB Provider for SQL Server -> A Demo Databse which store tables as per require data structure
b) On your 1st example :
rpt_Demo _rpt = new rpt_Demo()
where I use :
ReportDocument _rpt = new ReportDocument();
_rpt.Load(Server.MapPath("rpt_Demo.rpt"));

That's only the diff (I can not access rpt_Demo directly, it throwing [The type or namespace name 'rpt_Demo' could not be found (are you missing a using directive or an assembly reference?)]).

Sorry for lengthy reply.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900