Print Page | Close Window

Problem with Parameter report on deployment

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=14299
Printed Date: 01 May 2024 at 9:37pm


Topic: Problem with Parameter report on deployment
Posted By: Vamp10988
Subject: Problem with Parameter report on deployment
Date Posted: 08 Sep 2011 at 7:32am
Hello everyone, I'm not sure if this is a language specific forum but I am going to be posting C# code. I didn't see a C# crystal reports forum. I am having difficulty with reports that take parameters. I have a few reports that take primary key values as parameters. These values are automatically passed to the report via windows forms constructors. The code I have points to my report source in the development folder; however, when installation occurs, there no longer is a development folder and my reports do not load. Here is my code

ReportDocument cryRpt2 = new ReportDocument();
            ReportDocument cryRpt = new ReportDocument();
            try
            {
               cryRpt.Load("../../JuvenileArrest.rpt");
              
            }

            catch
            {
            }

            ParameterFieldDefinitions crParameterFieldDefinitions;
            ParameterFieldDefinition crParameterFieldDefinition;

            ParameterValues crParameterValues = new ParameterValues();
            ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

            crParameterDiscreteValue.Value = intCaseID;
            crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
            
            crParameterFieldDefinition = crParameterFieldDefinitions["CaseID"];
            crParameterValues = crParameterFieldDefinition.CurrentValues;

            crParameterValues.Clear();
            crParameterValues.Add(crParameterDiscreteValue);
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

            crystalReportViewer1.ReportSource = cryRpt;
            crystalReportViewer1.Refresh();

As you can see my report location "cryRpt" is located at "../../JuvenileArrest.rpt"

I tried to substitute the report source and crParameterFieldDefinitions = this.JuvenileArrest; instead and it worked in development but after deployment the program completely restarts itself with out any error message what so ever. When I had the report source set to "cryRpt" I got an error stating it could not locate the report and it is obvious because at the installation folder there is no .rpt file. I think those are located in some data file because all the other "non parameter" reports I have work flawleslly.



Print Page | Close Window