none
Display bulk of records in tabular format using Crystal report viewer. RRS feed

  • Question

  • Hi Everyone,

                    I would like to display application form as tabular format for that am using crystal report viewer..Here my issue is in my table I have bulk of data's but when i run my application it shows only 1st row of the table..I would like to display all the records which are present in table..

    Here am using C# winforms,visual studio 2010,sql server 2008..

    Here is my code:

      private void Report_Load(object sender, EventArgs e)
            {
                ReportDocument crystalreport = new ReportDocument();
                crystalreport.Load(@"D:\Development\VS2010 Projects\MVC Applications\Application_Print_CrystalReports\Application_Print_CrystalReports\leavereport.rpt");
                 //Here am writing query to display all the records which are present in the table
                Customers dscustomers = GetData("Select * From Leave_Form");
                crystalreport.SetDataSource(dscustomers);
                crystalReportViewer1.ReportSource = crystalreport;
                crystalReportViewer1.Refresh();
                crystalReportViewer1.Dock = DockStyle.Fill;
                this.Controls.Add(crystalReportViewer1);
            }
    
            //Here customers is my dataset name
            private Customers GetData(string query)
            {
                string conString = ConfigurationManager.ConnectionStrings["Myconn"].ConnectionString;
                SqlCommand cmd = new SqlCommand(query);
                using (SqlConnection con = new SqlConnection(conString))
                {
                    using (SqlDataAdapter sda = new SqlDataAdapter())
                    {
                        cmd.Connection = con;
                        con.Open();
                        sda.SelectCommand = cmd;
                        using (Customers dscustomers = new Customers())
                        {
                            sda.Fill(dscustomers, "DataTable1");
                            return dscustomers;
                        }
                    }
                }
            }

    Here is the snap shot of my application:


    Thanks & Regards RAJENDRAN M

    Friday, December 4, 2015 9:08 AM