C# Report Renderer for SRSS 2008 R2 - Missing Parameter

偶尔善良 提交于 2019-12-24 04:07:07

问题


I'm using C# to render a report from SRSS 2008 R2 The report has parameters and for a long time I have had no problem rendering the output. However today it has decided its not going to work!

Here is the error

ReportServerException: This report requires a default or user-defined value for the report parameter 'CustomFieldId'. To run or subscribe to this report, you must provide a parameter value. (rsReportParameterValueNotSet): Stack: at Microsoft.Reporting.WebForms.ServerReportSoapProxy.OnSoapException(SoapException e)

Here is the code:

ReportViewer rv = new ReportViewer();
rv.ShowCredentialPrompts = true;
rv.ProcessingMode = ProcessingMode.Remote;
rv.ServerReport.ReportServerUrl = new Uri(ReportsClient.ReportServerUrl);
rv.ServerReport.ReportPath = string.Format("/Reports/{0}", item.Name);
rv.ServerReport.SetParameters(thisLoopParams.ToArray());
rv.ServerReport.Timeout = -1;
rv.ServerReport.Refresh();

// render the report
string mimeType = string.Empty;
string extention = string.Empty;
string encoding = string.Empty;
string[] streamIds;
Microsoft.Reporting.WebForms.Warning[] warnings = null;

byte[] result = rv.ServerReport.Render(outputFormat, deviceInfo, out mimeType, out encoding, out extention, out streamIds, out warnings);

If I inspect thisLoopParams I can clearly see the 'CustomFieldId' ReportParameter and it definitely has a value, yet the error still appears.

Any ideas?


回答1:


Found it. I took a look at ReportParameterInfoCollection paramInfo = rv.ServerReport.GetParameters(); and found some of the parameters were 'Not Valid'. I know why but i was a bit thrown out by the original error of 'Not Provided'. I'm guessing this is because the valids i proided we just discounted

Thanks




回答2:



I am facing the same issue when i pass value of 'XYZ' field but it says

This report requires a default or user-defined value for the report parameter

when i see the value of 'XYZ' it has extra space in starting when i removed this space it surprisingly starts working.I don't know the reason but it works.Hope it may help you.



来源:https://stackoverflow.com/questions/14749348/c-sharp-report-renderer-for-srss-2008-r2-missing-parameter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!