Bruno Mayer
Bruno Mayer

Reputation: 133

Reporting Services (.RDLC) Two Datasets

I have a .rdlc with two datasources. When I was using only the Datasource named "dsLancamentos", it was working fine. Now, I've add a second one, named "dsDespesas", and the Report Viewer throws this message:

A data source instance has not been supplied for the data source 'dsDespesas'.

And here is my code:

var dsReportLancamentos = new dsReportLancamentosTableAdapters.PR_REPORT_LANCAMENTOSTableAdapter();
var dsReportDespesas = new dsReportLancamentosTableAdapters.PR_REPORT_SEA_DESPESASTableAdapter();
var tabela = (DataTable)dsReportLancamentos.GetData(txtNomeProduto.Text, Funcoes.GetDateTimeValueOrNull(DataDe), Funcoes.GetDateTimeValueOrNull(DataAte), Funcoes.GetByteValueOrNull(status));
var despesas = (DataTable)dsReportDespesas.GetData(Funcoes.GetDateTimeValueOrNull(DataDe), Funcoes.GetDateTimeValueOrNull(DataAte));


// CONFIGURAÇÕES DO REPORT -----------------------
ReportDataSource rds = new ReportDataSource("dsLancamentos", tabela);
ReportDataSource rdsDespesa = new ReportDataSource("dsDespesas", despesas);
rvReport.Reset();
rvReport.ProcessingMode = ProcessingMode.Local;
rvReport.LocalReport.ReportPath = Server.MapPath("~/reports/LancamentosReport.rdlc");
rvReport.LocalReport.DataSources.Add(rds);
rvReport.LocalReport.DataSources.Add(rdsDespesa);
// -----------------------------------------------

Can anyone help me with this? I just can't find whats wrong.

Tks.

Upvotes: 1

Views: 4580

Answers (2)

Murali Uppangala
Murali Uppangala

Reputation: 904

When you add a dataset in rdlc file you need to supply data to it,otherwise it will throw runtime error.Set data to each dataset with name specified in your code behind somethin like this-

 viewer.LocalReport.ReportPath = reportPath;
 viewer.LocalReport.DataSources.Add(new ReportDataSource("rdlc_dataset1", dataset.Tables[0]));
 viewer.LocalReport.DataSources.Add(new ReportDataSource("rdlc_dataset2", dataset.Tables[1]));

Upvotes: 0

Jatin patil
Jatin patil

Reputation: 4298

To update datasets in a report definition

1.Open the client report definition (.rdlc) file in Visual Studio Report Designer.

2.From the View menu, select Report Data. The Report Data window appears. Then To add a new dataset to the report definition, in the Report Data window's toolbar, select New, and then select Dataset.

3. Click Refresh to update the report definition file with your changes.

Upvotes: 1

Related Questions