我有SSRS报告。
当我使用http://localhost/reportserver的SSRS浏览器页面打开报告时,报告正常并加载数据。数据只有4行。
但是当我在报告查看器中嵌入报告时,加载意味着永远不会加载只显示进度状态。
我添加了option(recompile)
,但仍然没有结果。
以下是我的SP
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
select s.Name,s.Id as STUDENT_ID,a.AttendanceStatus,a.AttendanceDate,
case when (select count(*) from
Attendance where AttendanceStatus='Present')>
(select count(*) from Attendance where
AttendanceStatus='Absent') then 'Regular' else 'Not Regular' end as IsRegular
from Student s
inner join Attendance a on s.Id=a.Student_ID
where s.Id=@Student_Id
option(recompile)
END
以下是我用来在reportViewer中获取报告的C#代码
ReportViewer1.ServerReport.ReportServerUrl = new System.Uri("http://localhost/ReportServer");
ReportViewer1.ServerReport.ReportPath = "/Report1";
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
Microsoft.Reporting.WebForms.ReportParameter[] Param = new Microsoft.Reporting.WebForms.ReportParameter[1];
Param[0] = new Microsoft.Reporting.WebForms.ReportParameter("Student_Id","1");
ReportViewer1.ShowParameterPrompts = false;
ReportViewer1.ServerReport.SetParameters(Param);
答案 0 :(得分:-1)
我不知道它背后的任何逻辑,但我有同样的问题,在你的SP中声明一个新的变量并把" @ Student_Id"的值。首先在它中,然后在查询中使用这个新变量
希望它也适合你