我已经在SSRS中创建了报告,它运行良好,在构建器上根据需要显示记录。
现在,我想从windows应用程序中调用报告LOCALREPORT。我已经传递了报表所需的参数。但显示错误A data source instance has not been supplied for the data source Dataset1
代码如下:
ReportV.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;
LocalReport localreport = ReportV.LocalReport;
localreport.ReportPath = "Result.rdl";
ReportParameter _para_sid = new ReportParameter();
_para_sid.Name = "s";
_para_sid.Values.Add("313");
ReportParameter _para_courseid = new ReportParameter();
_para_courseid.Name = "Cid";
_para_courseid.Values.Add("BSB50207");
ReportParameter[] _rp = new ReportParameter[2];
_rp[1] = _para_sid;
_rp[0] = _para_courseid;
localreport.SetParameters(_rp);
ReportV.RefreshReport();
您正在本地处理,但您的报告是"Result.rdl"。rdl文件通常在SSRS服务器的上下文中运行。在ReportViewer控件中本地运行的报表通常具有RDLC扩展,并且是在Visual Studio中使用其设计器创建的。
是否有理由不在ReportViewer控件上使用远程处理模式?如果您试图从混合中消除SSRS服务器,我认为您必须将RDL报告转换为RDLC。它们非常相似,但并不完全相同。这里有一篇文章讨论了相反的翻译,但可能会有所启发——https://msdn.microsoft.com/en-us/library/ms252109.aspx.
如果使用Visual Studio中的设计器创建一个简单的RDLC报表,然后将其拖到窗体上,您将看到Visual Studio创建了一个DataSet、BindingSource和TableAdapter来读取报表的数据。我认为你需要做一些类似的事情来读取你的数据。
当然,如果是一个简单的报表,您可以在VS报表设计器中重新创建。