Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: problem passing parameter Post Reply Post New Topic
Author Message
dclarkwa
Newbie
Newbie


Joined: 20 Oct 2009
Online Status: Offline
Posts: 5
Quote dclarkwa Replybullet Topic: problem passing parameter
    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.

IP IP Logged
dclarkwa
Newbie
Newbie


Joined: 20 Oct 2009
Online Status: Offline
Posts: 5
Quote dclarkwa Replybullet 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.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.