Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am developing a c# application where I need to generate a report. I am a using a dataset which is filled with the data coming from a stored procedure which takes one parameter from the C# code. I am creating a parameter in report1.rdlc and populating it with the data from a text box. When I run the application I can’t see anything on report viewer. There is no error in my code. Someone please help as this an urgent requirement. I hope this makes sense.

Please review my code below:

C#
public void GenerateBranchwiseReport()
        {
            conn.Open();
            SqlCommand BranchReportcmd = new SqlCommand("select [am/bsi name] from masterlookup where [asc type]='BRANCH' group by [am/bsi name]", conn);
            SqlDataReader BranchReportread = BranchReportcmd.ExecuteReader();
            while (BranchReportread.Read())
            {
                BranchManagerName.Add(BranchReportread.GetValue(0).ToString());
            }
            conn.Close();
            foreach (string managername in BranchManagerName)
            {
                conn.Open();
                SqlCommand GetReportDatacmd = new SqlCommand();
                GetReportDatacmd.CommandText = "USP_BranchwiseReport";
                GetReportDatacmd.CommandType = CommandType.StoredProcedure;
                GetReportDatacmd.Parameters.Add(new SqlParameter("@BranchManagerName", managername));
                GetReportDatacmd.Connection = conn;
                GetReportDatacmd.ExecuteNonQuery();
                SqlDataAdapter da = new SqlDataAdapter(GetReportDatacmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                conn.Close();
                reportViewer1.Reset();
                this.reportViewer1.Visible = true;
                string reportname = @"d:\users\administrator\documents\visual studio 2010\Projects\ReportwithParameter\ReportwithParameter\Report1.rdlc";
                this.reportViewer1.LocalReport.ReportPath = @"d:\users\administrator\documents\visual studio 2010\Projects\ReportwithParameter\ReportwithParameter\Report1.rdlc";
                ReportParameter[] param = new ReportParameter[1];
                param[0] = new ReportParameter("ManagerName", managername);
                this.reportViewer1.LocalReport.SetParameters(param);
                ReportDataSource ReportBranch = new ReportDataSource("DatasetWithParameter.USP_BranchwiseReport", ds.Tables[0]);
                this.reportViewer1.LocalReport.ReportEmbeddedResource = reportname;
                this.reportViewer1.LocalReport.DataSources.Clear();
                this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DatasetWithParameter.USP_BranchwiseReport", ds.Tables[0]));
                //this.reportViewer1.LocalReport.DataSources.Add(ReportBranch);
                this.reportViewer1.LocalReport.Refresh();
                //SendEmail();
            }
        }
Posted
Comments
Sushil Mate 14-Jun-13 1:58am    
Did you debug the code? does the dataTable has the data? please refer this article for more info.


Dynamic-Binding-Of-RDLC-To-ReportViewer!
waris kantroo 14-Jun-13 2:01am    
Yes i debugged the code.It is coming in the datatable but it is not binding the data to the report viewer i think.

KarthickInfosys 17-Jun-13 5:28am    
Can you tell me how you write the ASP.NET code?.

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