为数据源与RDL报告的ReportViewer [英] Datasource for RDL reports with ReportViewer

查看:671
本文介绍了为数据源与RDL报告的ReportViewer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与SQL Server商业智能开发Studio中创建一些RDL报告和现在我需要使用ASP.NET报表查看器,使它们。虽然我RDLs包含对SQL服务器和SELECT查询引用,它口口声声说我需要指定报表的数据源。有没有一种方法,使从RDL数据源中使用或做我有一个数据源传递给通过C#code中的报表查看器?

I have some RDL reports created with SQL Server BI Development Studio and now I need to render them using the ASP.NET Report Viewer. Even though my RDLs contain references to the SQL server and the SELECT query, it keeps saying I need to specify a datasource for the report. Is there a way to make the datasource from the RDL be used or do I have to pass a datasource to the report viewer via C# code?

感谢您。

推荐答案

你验证您的RDL元素DataSourceReference?它需要的路径到报告服务器。

Did you verify the DataSourceReference element in your RDL? It needs the path to the reporting server.

该DataSourceReference元素可以包含一个完整的文件夹路径(
  例如,/ SampleReports /的AdventureWorks)或相对路径(
  例如,AdventureWorks的)。相对路径在同一文件夹中启动
  那个报告。共享数据源必须是相同的服务器上
  报告。

The DataSourceReference element can contain a full folder path (for example, /SampleReports/AdventureWorks) or a relative path (for example, AdventureWorks). Relative paths start in the same folder as the report. The shared data source must be on the same server as the report.

验证的DataSourceID了。看看在<一个href=\"http://stackoverflow.com/questions/1797180/using-a-shared-data-source-for-dynamically-generated-and-deployed-reports\">answer在这个问题上。它看起来像它可能是你有同样的问题。

Verify the DataSourceID too. Take a look at the answer on this question. It looks like it might be the same problem you are having.

如果您使用的是您还可以设置报表的数据源的RDLC使用的 ReportDataSource 。 GetMyData,在下面的例子将实现IEnumerable或的IDataSource。

If you are using an RDLC you could also set the datasource of your report manually using ReportDataSource. "GetMyData" in the example below would implement IEnumerable or IDataSource.

ReportDataSource reportDataSource = new ReportDataSource("MyDataName", GetMyData(startAt, endAt));
ReportViewer1.LocalReport.DataSources.Add(reportDataSource);
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reporting/MyReport.rdlc");

ReportParameterCollection col = new ReportParameterCollection();
ReportParameter startAtParam = new ReportParameter("StartAt", startAt.ToString("MMM, dd yyyy"));
col.Add(startAtParam);
ReportParameter endAtParam = new ReportParameter("EndAt", endAt.ToString("MMM, dd yyyy"));
col.Add(endAtParam);

ReportViewer1.LocalReport.SetParameters(col);   

如果您是一个RDL转换为RDLC就可以的按照步骤这里。请注意,您需要重新创建数据源和查询信息。此外,XML模式定义为2005年至2008年间的不同。

If you are converting an RDL to an RDLC you can follow the steps here. Note that you need to re-create data source and query information. Also, the XML schema definition is different between 2005 and 2008.

这篇关于为数据源与RDL报告的ReportViewer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆