This is a migrated thread and some comments may be shown as answers.

Invalid Parameter Value while programmatically rendering report

2 Answers 280 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 07 Aug 2012, 09:21 PM
I'm using Q1 2012 for an MVC 3 Application where a report is generated, attached to an email and sent.  The parameters are applied from an object model containing all report parameters and strings representing each value.  When applying the value in plain text, the report runs and attaches to the email as it should
EX.
Report.ReportParameter.Value[0] = "Value"

But when doing the same from the model, I receive an inner exception for an invalid parameter

Working Code:
rpt.ReportParameters[4].Value = Reporting.GetParametersObject("VAL1; VAL2");

But when the code is changed to this:
rpt.ReportParameters[4].Value = Reporting.GetParametersObject(email.EmailReportParameters.ToString());

I receive and inner exception error and the parameter value returns to null.

The GetParametersObject converts a string to an Object[].

The debugger shows the same values in both cases as type {string[]}

Model: (I've also tried an Object[] for EmailReportParameters with the same result)
public class EmailReport
    {
        public string EmailAddress { get; set; }
        public string EmailAttachmentExtension { get; set; }
        public string EmailAttachName { get; set; }
        public string EmailSubject { get; set; }
        public string EmailBody { get; set; }
        public String[] EmailReportParameters { get; set; }
    }

Single value parameters are working properly:
rpt.ReportParameters[0].Value = email.EmailReportParameters[0];

Error Detail:
InnerException   {"Invalid value of report parameter 'LineOfBusiness1'."}
 
   at Telerik.Reporting.Processing.Report.ResolveData()
   at Telerik.Reporting.Processing.Report.ProcessItem()
   at Telerik.Reporting.Processing.ReportItemBase.Process(DataMember data)
   at Telerik.Reporting.Processing.Report.Process(DataMember data, DataItemState state, Boolean processItemActions, Boolean documentMapEnabled)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessReport(IReportDocument reportDocument, IDictionary processingContext)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessReport(IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessAndRender(String format, IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext, CreateStream createStreamCallback)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessAndRenderStateless(String format, IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext, CreateStream createStreamCallback)
   at Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo)
   at compucom.TrackIT.Reports.Controllers.EmailReportController.SendEmailReport(EmailReport email) in C:\Users\tk83673\Documents\Projects\ITOProdSolutions\TrackIT\USBank\compucom.TrackIT.Reports\Controllers\EmailReportController.cs:line 76
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)

2 Answers, 1 is accepted

Sort by
0
IvanY
Telerik team
answered on 10 Aug 2012, 04:12 PM
Hello Thomas,

It will be best to send us a running sample that exhibits your issue. We were unable to reproduce such a problem at our end and your code seems to be ok. However we cannot be sure as we do not know your full source code.

Having in mind the error, you may be trying to export a report with empty parameters for example (if the string has no values in it - please check if there are values in the array at all times and also at the right time).

Regards,
IvanY
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Thomas
Top achievements
Rank 1
answered on 17 Aug 2012, 04:06 PM
Thanks for looking into this.  I found my issue.

When the parameters were collected from the Parameters table, it contained invisible characters.  I used a regex to cleanup the strings before applying them to the procedure.
Tags
General Discussions
Asked by
Thomas
Top achievements
Rank 1
Answers by
IvanY
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or