Reputation: 53
i am creating my rdlc report through creating dataset but when i run my report this error occur "A data source instance has not been supplied for the data source 'DataSet1'" i also changed the dataset name but no improvement .i give datasource through to report viewer through smart tag.
Upvotes: 4
Views: 21658
Reputation: 2612
In case, if you are binding the DataSource to Report by code,
DataSet name "FinancialRatios" and Table name "FinInfo"
I tried by specifying DataSet and Table name separately as below
ReportDataSource datasource = new ReportDataSource("FinancialRatios", dsFinRatios.Tables[0]);
and
ReportDataSource datasource = new ReportDataSource("FinInfo", dsFinRatios.Tables[0]);
In both cases the error was "A data source instance has not been supplied for the data source 'FinancialRatios_FinInfo'."
So I set the DataSource to "FinancialRatios_FinInfo" as mentioned in the error and it worked.
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/FinRatioReport.rdlc");
ReportDataSource datasource = new ReportDataSource("FinancialRatios_FinInfo", dsFinRatios.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
Upvotes: 0
Reputation: 1265
Seems you didn't set Data Source to Report Viewer Data Sources yet.
You can check this by many ways, I will suggest you two ways followings:
In aspx file, at ReportViewer
tag, make sure that you have <DataSources>
setting in the <LocalReport>
tag. See my sample code:
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
<LocalReport ReportPath="Report.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="SqlDataSource1" Name="DataSet1" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
To set DataSourceId properties of <ReportDataSource>
tag is mandatory.
Otherwise you could set report data source instance to ReportViewer in design view. See the picture below:
ReportViewer Tasks > Choose Data Source > Data Source Instance
Upvotes: 5