Tuesday, March 27, 2012

A data source instance has not been supplied for the data source

Hi Guys,

I have create a report and it works in development mode. But when I call this report from aspx page it give me above error message. Please let me know how can I setup datasource of this report at runtime. Below is my code

Regards

ReportParameter[] rptPara = new ReportParameter[1];

rptPara[0] = new ReportParameter("rDate", WebDateChooser1.Text, false);

ReportViewer1.LocalReport.ReportPath = @."C:Business\RPT585.rdl";

ReportViewer1.LocalReport.SetParameters(rptPara);

ReportViewer1.LocalReport.Refresh();

Please anybody could let me guide here....

|||

This is how you can provide DataSource information to report at runtime.

Example:

ObjectDataSource objAdventureWorks = new ObjectDataSource("MyData", "GetDataAddress");

objAdventureWorks.ID = "Adventureworks";

this.Controls.Add(objAdventureWorks);

this.ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("AdventureWorks2000", "Adventureworks"));

|||

I have added the datasource of my report but still keep getting this error message. Please let me guide how to fix this error. adn how to set data source instance. Below is my code

ReportParameter[] rptPara = new ReportParameter[1];

rptPara[0] = new ReportParameter("rDate", WebDateChooser1.Text, false);

ReportViewer1.LocalReport.ReportPath = @."C:\business\RPT528.rdl";

ReportViewer1.LocalReport.SetParameters(rptPara);

ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dsCustomers"));

ReportViewer1.LocalReport.Refresh();

|||

http://blogs.msdn.com/bimusings/archive/2005/07/01/434659.aspx

I think this article should answer your question. I was experiencing the same error and Russell's work-around fixed it.

TF

No comments:

Post a Comment