0

I'm trying to display report in reportviewer i'm using the following code.

private void button1_Click(object sender, EventArgs e)
        {
            DataSet ds = GetData();
            ReportDataSource datasource = new ReportDataSource("Power7000_ICCard_Prepayment_System.Form_RpttotalMonthConsumptionReport.rdlc", ds.Tables[0]);
            reportViewer1.LocalReport.DataSources.Clear();
            reportViewer1.LocalReport.DataSources.Add(datasource);
            reportViewer1.RefreshReport();
        }
private DataSet GetData()
        {
            
            string Query = @"select tmc.customer_id,toc.Customer_name,toc.meterNo, tmc.date, tmc.consumption from public_month_consumption_record tmc
                                INNER JOIN public_openaccount1 toc ON tmc.customer_id = toc.Customer_id
                                where MONTH(tmc.date) = '" + SelectedMonth + "' AND YEAR(tmc.date) = '" + SelectedYear + "';";

            dt = DLL_Common.SysGlobal.DataBaseAccess.GetDataTable(Query);
            

            decrypted_dt = dt;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                decrypted_dt.Rows[i][0] = DLL_Business.DatabaseEncryption.GetDecrypt(dt.Rows[i][0].ToString().Trim());
                decrypted_dt.Rows[i][1] = DLL_Business.DatabaseEncryption.GetDecrypt(dt.Rows[i][1].ToString().Trim());
                decrypted_dt.Rows[i][2] = DLL_Business.DatabaseEncryption.GetDecrypt(dt.Rows[i][2].ToString().Trim());
                decrypted_dt.Rows[i][3] = dt.Rows[i][3] ;
                decrypted_dt.Rows[i][4] = dt.Rows[i][4];
            }

            DataTable dtCopy = decrypted_dt.Copy();
            DataSet ds = new DataSet();
            ds.Tables.Add(dtCopy);
            return ds;
        }

but the reportviewer error :

the source of the report definition has not been specified

  • after adding the datasource to reportviewer plaease use reportViewer1.LocalReport.ReportEmbeddedResource = "Power7000_ICCard_Prepayment_System.Form_RpttotalMonthConsumptionReport.rdlc"; – Nadeem Taj Aug 22 '20 at 09:14
  • **ReportViewer Exception**: A data source Instance has not supplied for the data source _**DataSourceName**_ – Elmsrya esmc Aug 22 '20 at 16:15
  • After Changing Data Source "[https://stackoverflow.com/questions/13332611/a-data-source-instance-has-not-been-supplied-for-the-data-sourceproduct-detail](https://stackoverflow.com/questions/13332611/a-data-source-instance-has-not-been-supplied-for-the-data-sourceproduct-detail)" After Checking This Link Thanks For Your Help – Elmsrya esmc Aug 22 '20 at 17:45

1 Answers1

0

You need to set the report path.

reportViewer.LocalReport.ReportPath = "";

Here is the stack overflow link

The source of the report definition has not been specified

Biju Kalanjoor
  • 532
  • 1
  • 6
  • 12
  • to be like that ? `reportViewer1.LocalReport.ReportPath = @"Power7000_ICCard System\Form_Rpt\totalMonthConsumptionReport.rdlc";` – Elmsrya esmc Aug 22 '20 at 07:42
  • Can you please check the link which I provided. Which gives you more understanding rather than I explain it here. If you still get issue we can take a look. – Biju Kalanjoor Aug 22 '20 at 07:48
  • not yet is just try to understand what's the different between `report[0] = new ReportParameter("MyName", "Raha");` ` var reportDataSource1 = new ReportDataSource { Name = "WpfApplication17_User", Value = _users }; ` – Elmsrya esmc Aug 22 '20 at 12:10