C# .NET - RDLC REPORTS - Asked By remya on 23-May-10 03:15 AM

I created a RDLC report programatically..
Binded data from table to dataset through code and then connected data set to reportviewer..

Code

using



System;



using



System.Collections;



using



System.Configuration;



using



System.Data;



using



System.Linq;



using



System.Web;



using



System.Web.Security;



using



System.Web.UI;



using



System.Web.UI.HtmlControls;



using



System.Web.UI.WebControls;



using



System.Web.UI.WebControls.WebParts;



using



System.Xml.Linq;



using



System.Data.OleDb;



using



Microsoft.Reporting.WebForms;



public



partial class Default2 : System.Web.UI.Page




{



protected void Page_Load(object sender, EventArgs e)

{



string cnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\LENOVO\\Documents\\Products.accdb";


//Declare Connection, command and other related objects






OleDbConnection conReport = new OleDbConnection(cnString);


OleDbCommand cmdReport = new OleDbCommand();


OleDbDataReader drReport;


DataSet dsReport = new dsProductDrillDown();


try




{

conReport.Open();

cmdReport.CommandType =


CommandType.Text;

cmdReport.Connection = conReport;

cmdReport.CommandText =


"Select * FROM tblProduct";

drReport = cmdReport.ExecuteReader();

dsReport.Tables[0].Load(drReport);

drReport.Close();

conReport.Close();

ReportViewer1.LocalReport.ReportPath =


"C:\\Users\\LENOVO\\Documents\\Visual Studio 2008\\Projects\\Assignment1\\Assignment1\\Report1.rdlc";


ReportDataSource rds = new ReportDataSource();

rds.Name =


"dsProductDrillDown_dtProductDrillDown";

rds.Value = dsReport.Tables[0];

ReportViewer1.LocalReport.DataSources.Add(rds);



this.ReportViewer1.LocalReport.Refresh();


//provide local report information to viewer






// String reportPath= "C:\\Users\\LENOVO\\Documents\\Visual Studio 2008\\Projects\\Assignment1\\Assignment1\\Report1.rdlc";






//reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;






//reportViewer1.LocalReport.ReportPath = "C:\\Users\\LENOVO\\Documents\\Visual Studio 2008\\Projects\\Assignment1\\Assignment1\\Report1.rdlc";






//reportViewer1.LocalReport.DataSources.Clear();






//reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dsProductDrillDown", dsReport.Tables[0]));






//reportViewer1.DocumentMapCollapsed = true;






//reportViewer1.RefreshReport();






// ReportDataSource rds = new ReportDataSource();






// rds.Name = "dsProductDrillDown_dtProductDrillDown";






//






// reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dsProductDrillDown_dtProductDrillDown", dsReport.Tables[0]));






// reportViewer1.LocalReport.ReportEmbeddedResource = "Report1.rdlc";






// // rView.LocalReport.DataSources






//// .Add(new ReportDataSource("HESAP_PLAN_dtLast", dsHesapPlan.Tables[0]));






// //reportViewer1.LocalReport.ReportPath = reportPath;






// this.reportViewer1.RefreshReport();




}



catch (Exception ex)

{



//display generic error message back to user






//Response.Write(ex.Message);




}



finally




{



//check if connection is still open then attempt to close it






if (conReport.State == ConnectionState.Open)

{

conReport.Close();

}



// this.reportViewer1.RefreshReport();




}



//this.reportViewer1.RefreshReport();





}

}




But when i execute the error arises in webpage...
  • A data source instance has not been supplied for the data source 'dsProductsDrillDown_dtProductDrillDown'.
Please Help me....

Anoop S replied to remya on 23-May-10 05:59 AM
You should use Getdata() method to get data to report

ReportDataSource rds = new ReportDataSource("dsProductDrillDown_dtProductDrillDown", GetData());

remya replied to Anoop S on 23-May-10 10:48 AM
Thanks for instant reply..But i m not getting GetData() method...is it in built function?

what is the definition for GetData() method??
Anoop S replied to remya on 23-May-10 11:27 AM
you need to call your tableadapter_object.GetData()
refer this links
http://www.gotreportviewer.com/definedata/index.html
http://www.codeproject.com/KB/cs/Email_a_PDF_Report.aspx