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?
Thank you.
Did you verify the DataSourceReference element in your RDL? It needs the path to the reporting server.
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.
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.
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);
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.