cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding the Report's Default Value

Former Member
0 Kudos

Now the default value of the CrystalDecisions.CrystalReports.Engine is empty which is a problem clarified by both Luke and Don Williams. Don provided a good tips for code, referring Don's reply at Jan 10, 2014 and Jul 31, 2012, I’ve tested this and it is worked, and I got a default value. However, the other sever problem has been occurred. Since the unmanaged code (COM) can't construct (casting) to the managed code directly, since it is a interface. Otherwise the original all Crystal Document objects will be wiped out, and become null value. Here is my analysis referred Don’s code:

foreach (CrystalDecisions.ReportAppServer.DataDefModel.ParameterField rasParamfield in                                                             myReport.ReportClientDocument.DataDefController.DataDefinition.ParameterFields)

{ ….

Here myReport is coming from CrystalDecisions.CrystalReports.Engine.ReportDocument, so this code will not be useful if you want to keep myReport active. From this point, I do not know what another alternatives could be used to achieve this or using Reflection , and how?

Any responses would be so appreciated.

J. Huang

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Johnson,

Correct, but mostly it works without having to set the viewer to the RAS Report Object but just in case you do then I use a flag id RAS has modified the report and set the viewer accordingly:

You still need to open the report by the Engine but then assign it to the RAS client Doc:

add these assemblies:

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

using CrystalDecisions.ReportAppServer;

using CrystalDecisions.ReportAppServer.ClientDoc;

using CrystalDecisions.ReportAppServer.Controllers;

using CrystalDecisions.ReportAppServer.ReportDefModel;

using CrystalDecisions.ReportAppServer.CommonControls;

using CrystalDecisions.ReportAppServer.CommLayer;

using CrystalDecisions.ReportAppServer.CommonObjectModel;

using CrystalDecisions.ReportAppServer.ObjectFactory;

using CrystalDecisions.ReportAppServer.Prompting;

using CrystalDecisions.ReportAppServer.DataSetConversion;

using CrystalDecisions.ReportAppServer.DataDefModel;

using CrystalDecisions.ReportSource;

Global flag:

bool IsRpt = true;

CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc;

In the routine to you update the values add IsRpt =  false;

In your open method use this:

rptClientDoc = new CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocument();

rpt.Load(rptName.ToString(), OpenReportMethod.OpenReportByTempCopy);

rptClientDoc = rpt.ReportClientDocument;

Then in the view report button use this:

try

{

    if (!IsRpt)

    {

        crystalReportViewer1.ReportSource = rptClientDoc.ReportSource;

    }

    else

    {

        crystalReportViewer1.ReportSource = rpt;

    }

}

catch (Exception ex)

{

    btnSQLStatement.Text = "ERROR: " + ex.Message;

}

Don

Former Member
0 Kudos

Hi Don,

Thank you so much for your very proactive responses. We have lots of processes in the backend server side, and create an instance of Viewer without any prompts are inevitable, since some of functions now must be gone through with the Viewer.

You tips are very make sense, but what I’ve tried is that passing the report’s name, then to create an another instance of this report by this name, so using this new instance to achieve what I want, and original object report is seemed to be save.

Thanks again,

  1. Huang
0 Kudos

Then you need to make sure you are using the right instance of the report. Try opening a different report the second time as a test to see what happens, which report is being saved.

Don

Answers (0)