Print Page | Close Window

problem passing parameter

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=8570
Printed Date: 05 May 2025 at 8:09am


Topic: problem passing parameter
Posted By: dclarkwa
Subject: problem passing parameter
Date Posted: 05 Dec 2009 at 11:13am
I use VS2008, with built in Crystal Decisions.  I am trying to pass parameters to an ASP.net application programatically.

When I run the application and step through it in development mode, I can see that all three parameters are passed to the reportviewer.ParameterFieldInfo property.  However the application then asks for the third parameter using the user input parameter screen as if it did not get passed.  If I enter a value for it, I then get another user input parameter screen asking for the first two parameters, and so on, back and forth without ever displaying the report.

Here is my code:

protected void Page_Load(object sender, EventArgs e)

{

if (!Page.IsPostBack)

{

ReportDocument reportDocument = new ReportDocument();

ParameterFields paramFields = new ParameterFields();

ParameterField paramFieldAgency = new ParameterField();

ParameterDiscreteValue paramAgencyDiscreteValue = new ParameterDiscreteValue();

//Set instances for input parameter 1 - @agencyName

paramFieldAgency.Name = "@agencyName";

//*Remember to reconstruct the parameterDiscreteValue

//and parameterField objects

paramAgencyDiscreteValue.Value = Session["agencyName"].ToString();

paramFieldAgency.CurrentValues.Add(paramAgencyDiscreteValue);

ParameterField paramFieldStartDate = new ParameterField();

ParameterDiscreteValue paramStartDateDiscreteValue = new ParameterDiscreteValue();

//Set instances for input parameter 2 - @startdate

paramFieldStartDate.Name = "@startdate";

//*Remember to reconstruct the parameterDiscreteValue

//and parameterField objects

paramStartDateDiscreteValue.Value = Session["reportStartDate"].ToString();

paramFieldStartDate.CurrentValues.Add(paramStartDateDiscreteValue);

ParameterField paramFieldEndDate = new ParameterField();

ParameterDiscreteValue paramEndDateDiscreteValue = new ParameterDiscreteValue();

//Set instances for input parameter 3 - @endDate

paramFieldEndDate.Name = "@endDate";

//*Remember to reconstruct the parameterDiscreteValue

//and parameterField objects

paramEndDateDiscreteValue.Value = Session["reportEndDate"].ToString();

paramFieldEndDate.CurrentValues.Add(paramEndDateDiscreteValue);

//Add the paramField to paramFields

paramFields.Add(paramFieldAgency);

paramFields.Add(paramFieldStartDate);

paramFields.Add(paramFieldEndDate);

AgencyUtsteinCrystalReportViewer.ParameterFieldInfo = paramFields;

reportDocument.Load("myAbsolutePath");

//Load the report by setting the report source

AgencyUtsteinCrystalReportViewer.ReportSource = reportDocument;

//set the database loggon information.

AgencyUtsteinCrystalReportViewer.Visible = true;

reportDocument.SetDatabaseLogon("myUserName", "myPassword", "mySQLServer", "myDatabasee");

AgencyUtsteinCrystalReportViewer.DataBind();

}

}

Does anyone know why and how to fix this?  Any help would be greatly appreciated.




Replies:
Posted By: dclarkwa
Date Posted: 05 Dec 2009 at 12:07pm
I was able to solve this by going to the properties of the CrystalReportViewer in the .aspx page and setting "Enable ParameterPrompting" to False.



Print Page | Close Window