A data source instance was not provided for the data source.

I'm currently trying to dynamically send an rdl report to my ReportViewer.net object.

I keep getting an error when I do this: a data source instance was not provided for the blah data source

I am trying to spot a β€œblah” in my code behind at runtime.

ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = ReportFile; ReportViewer1.LocalReport.DataSources.Clear(); Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(); rds.Name = "blah"; ReportViewer1.LocalReport.DataSources.Add(rds); ReportViewer1.DocumentMapCollapsed = true; ReportViewer1.LocalReport.Refresh(); 

it does not work in a long shot . I'm not sure what I should do. here is an excerpt from the top of my rdl file:

  <DataSource Name="blah"> <rd:DataSourceID>c6a8409e-71a4-4e96-86ad-b300a5b942c3</rd:DataSourceID> <ConnectionProperties> <DataProvider>SQL</DataProvider> <ConnectString>Data Source=10.555.121.121;Initial Catalog=blah</ConnectString> <IntegratedSecurity>true</IntegratedSecurity> </ConnectionProperties> </DataSource> </DataSources> 

All I'm trying to do is just select * from the table in β€œblah” in my report. I need this to work because I have many other report instances that I need to show inside my ReportViewer. Why doesn't Microsoft make it easier?

Thanks in advance somebody ...

+4
source share
1 answer

The ReportViewer control is designed to work locally with RDLC report files, not with RDL report files. The ReportViewer control is intended only for rendering the report and therefore ignores any data set and connection information that may be present (i.e. if you use the RDL file instead of the RDLC file). It is assumed that you create any connections, query data sources, put the results in DataTables and add them to create the reportDataSource data sources for the ReportViewer control in the calling application.

From MSDN:

In local processing mode, the control opens the report definition, processes it, and then displays the report in the viewing area. In local, you can get the report definition from a .rdlc file in the file system, stream, or embedded resource in your application.

Additional Information: Adding and Customizing ReportViewer Controls

See also: When to use RDLC over RDL reports?

0
source

All Articles