Click here to Skip to main content
15,880,967 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello All

I am using reportwizard for reports.
i am using MicrosoftReportViewer to show these reports.
i want to choose report to show in reportviewer at runtime.
for this i am using following code :


private void Report_Load(object sender, EventArgs e)
        {
            reportViewer1.ProcessingMode=ProcessingMode.Local;
            LocalReport lr = reportViewer1.LocalReport;
            lr.ReportPath = AppDomain.CurrentDomain.BaseDirectory+"..\\..\\Reports\\rptSaleHotel.rdlc";
            SqlDataAdapter adp = new SqlDataAdapter("HotelSale", ConfigurationManager.ConnectionStrings["cn"].ConnectionString);
            adp.SelectCommand.CommandType = CommandType.StoredProcedure;
            adp.SelectCommand.Parameters.Add("@from",SqlDbType.DateTime).Value="02-02-2011";
            adp.SelectCommand.Parameters.Add("@to", SqlDbType.DateTime).Value = "02-17-2011";
            DataSet ds = new DataSet();
            adp.Fill(ds);
            ReportDataSource rds = new ReportDataSource();
            this.reportViewer1.LocalReport.DataSources.Clear();
            rds.Value = ds.Tables[0];
            rds.Name = "salehotel";
            string st=lr.ReportPath.ToString();
            lr.DataSources.Add(rds);      
        }



but it is showing totally blank report and a message
A datasource instance has not been supplied for the datasource 'dbTraDeskDatase_HotelSale'.i have checked the value in dataset it contain 6 records.

can anyone please tell me where i am wrong


thanks in advance
Posted
Updated 13-May-20 23:54pm
v2
Comments
Member 10957757 14-May-20 5:56am    
thank you so much bro. your code very helpfull

i got the answer.
i was wrong at
rds.Name = "salehotel";
here i have to give
rds.Name = "dbTraDeskDataSet_HotelSale";
i.e. the name of datasource.


thanks
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900