Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Specified cast is not valid" when using Crystal Rep params in asp.net

Status
Not open for further replies.

handleeldnah

Programmer
May 29, 2003
2
CA
Hello,

I am trying to use a WebService(.net) built based on a Crystal report that uses an parameter(address.code).
When I build the Client to access the WebService I used the attached code in order to send the parameter values.

If I try to access the Client in Internet Explorer, I get
"Exception Details: System.InvalidCastException: Specified cast is not valid.
"
I commented out the last line and it seems that there is the problem.

How could I solve this?


base.OnInit(e);
CrystalReportViewer1.ReportSource = new localhost.TenantsService();
// Declare variables needed to pass the parameters
// to the viewer control.
ParameterFields paramFields = new ParameterFields ();
ParameterField paramField = new ParameterField ();
ParameterDiscreteValue discreteVal = new ParameterDiscreteValue ();

// The first parameter is a discrete parameter with multiple values.

// Set the name of the parameter field, this must match a
// parameter in the report.
paramField.ParameterFieldName = "addrcode";

// Set the first discrete value and pass it to the parameter.
discreteVal.Value = "Smith";
paramField.CurrentValues.Add (discreteVal);

// Set the second discrete value and pass it to the parameter.
// The discreteVal variable is set to new so the previous settings
// will not be overwritten.
discreteVal = new ParameterDiscreteValue ();
discreteVal.Value = "ABCSuppli";
paramField.CurrentValues.Add (discreteVal);

// Add the parameter to the parameter fields collection.
paramFields.Add (paramField);

// Set the parameter fields collection into the viewer control.

// Here the left part has unknown value and it gave the error
CrystalReportViewer1.ParameterFieldInfo = paramFields;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top