on 11-21-2008 6:28 PM
Hi we have this situation:
We migrated a WinForms application from VS2003 to VS2008 and now we have a problem with crystal reports 10.5(the version that is bundled with VS2008), when we execute some reports, they show me the error "The parameter is incorrect", but this only happend with reports that have subreports.
The weird thing is that if we don't set the parameters (by code) and execute the report, the viewer show me the window parameter and after we enter the parameters in that window, the report works fine!!!!
Someone with any idea what could be the problem?
Thanks.
Hi,
Have you code for the sub-report parameters seperately.
I would like you to know the following code that I have tried at my end using Viewer Object model:
// Object Declaration
ParameterFields boParameterFields = null;
ParameterField boParameterField = null;
ParameterValues boParameterValues = null;
ParameterDiscreteValue boParameterDiscreteValue = null;
ParameterRangeValue boParameterRangeValue = null;
// loading the report
CrystalReportViewer1.ReportSource = Server.MapPath("ReportWithSubReport.rpt");
CrystalReportViewer1.RefreshReport();
// passing database credentials...
foreach(CrystalDecisions.Shared.TableLogOnInfo boTableLogOnInfo in CrystalReportViewer1.LogOnInfo)
{
ConnectionInfo boConnectionInfo = boTableLogOnInfo.ConnectionInfo;
boConnectionInfo.UserID ="sa";
boConnectionInfo.Password="sa";
}
// Parameter Country
boParameterFields = CrystalReportViewer1.ParameterFieldInfo;
boParameterField = boParameterFields["Country"];
boParameterValues = boParameterField.CurrentValues;
boParameterDiscreteValue = new ParameterDiscreteValue();
boParameterDiscreteValue.Value = "Argentina";
boParameterValues.Add(boParameterDiscreteValue);
// Parameter Sales
boParameterField = boParameterFields["Sales"];
boParameterValues = boParameterField.CurrentValues;
boParameterRangeValue = new ParameterRangeValue();
boParameterRangeValue.StartValue = 25000;
boParameterRangeValue.EndValue = 100000;
boParameterValues.Add(boParameterRangeValue);
// Parameter @percentage in subreport named SubReport
boParameterField = boParameterFields["@percentage", "SubReport"];
boParameterValues = boParameterField.CurrentValues;
boParameterValues.Clear();
boParameterDiscreteValue = new ParameterDiscreteValue();
boParameterDiscreteValue.Value = 75;
boParameterValues.Add(boParameterDiscreteValue);
Please note that I have used Range and Discrete values as parameter in the above code.
Also if you want to use the ReportDocument Object model then you can use:
ReportDocument.SetParameterValues("Parameter name", value)
Note:- This code is valid for only discrete values of Parameters.
or
boParameterFieldDefinitions = boReportDocument.DataDefinition.ParameterFields;
boParameterFieldDefinition = boParameterFieldDefinitions["@percentage","SubReport"];
boParameterValues = boParameterFieldDefinition.CurrentValues;
Hope this will help!!
Regards,
Amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Field Definitions Only driver is not shipped with Cr Basic. Need to upgrade to Full version of Crystal Reports
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Another thing is that, all our reports were created with "Field Definitions Only" (.ttx files) and VS2003 and now the CR version bundled in VS2008 doesn't have this option available.
Someone?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Our subreports doesn't have parameters, only the one to make the link between the main report and the subreport.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
69 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.