簡體   English   中英

在c#中將參數值設置/傳遞給Crystal報表不起作用

[英]Setting/Passing a Value to a Parameter to a Crystal Report in c# is Not Working

我有兩個在Crystal Report中創建的參數(詳細信息,摘要)。 在Windows窗體應用程序中從c#調用該報告。 我試圖在運行時將適當的值傳遞給每個參數,以便報表可以基於這些值做出一些決策。 我已經閱讀了很多有關此的文章,我認為我正在使用最好的方法來完成此任務?

這是我在加載報告之后和設置SetDataSoruce之前實現的簡單代碼:

crReportDocument.SetParameterValue("DetailView", false);
crReportDocument.SetParameterValue("SummaryView", true);

由於某些原因,這些值未到達報告,因為報告始終在運行時提示您設置值。

有關該報告的所有其他信息都可以正常運行。

我希望有人能對此事提供任何啟發,因為這似乎很簡單?

問題是必須使用格式{?PARAMETER}傳遞{?PARAMETER} 有用。

crReportDocument.SetParameterValue("{?DetailView}", false);

crReportDocument.SetParameterValue("{?SummaryView}", true);

實際上,問題出在代碼放置。 我在錯誤的代碼執行位置填充了參數:

這是它在不起作用時的處理方式:

crReportDocument.SetParameterValue("FromDate", dtmFromDate);
ReportViewer reportViewer = new ReportViewer();
reportViewer.ReportSource = crReportDocument;

為了解決這個問題,我將代碼移動如下:

ReportViewer reportViewer = new ReportViewer();
reportViewer.ReportSource = crReportDocument;
crReportDocument.SetParameterValue("FromDate", dtmFromDate);

這就是使其正常工作所需要的。 讓我知道它是否不適合您。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM