Click here to Skip to main content
15,907,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I made a database contains employee details, now i have to generate a report based on the data in employee database, i use report viewer and the following code has used:-


C#
private void Report_Load(object sender, EventArgs e)
        {
            UseWaitCursor = false;
            this.reportViewer1.RefreshReport();
        
        }
        private DataTable getData()
        {
            String ConnectionString = System.Configuration.ConfigurationManager.AppSettings["DRDOHRDataBase"];
            OleDbConnection myConnection = new OleDbConnection(ConnectionString);
            string query = "SELECT Desig, COUNT(*) AS Held FROM HRData GROUP BY Desig WHERE status='1'";
            OleDbDataAdapter myAdapter = new OleDbDataAdapter(query, myConnection);
            DataSet ds = new DataSet();
            myAdapter.Fill(ds, "HRData");
            ds.Tables[0].TableName = "HRData";
            return ds.Tables[0];  
        }
        private void reportViewer1_Load(object sender, EventArgs e)
        {
            this.reportViewer1.Reset();
            reportViewer1.ProcessingMode = ProcessingMode.Local;
            LocalReport localReport = reportViewer1.LocalReport;
            this.reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
            ReportDataSource rds = new ReportDataSource("DataSet1", getData());
            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(rds);
            //this.reportViewer1.DataBind();
            this.reportViewer1.LocalReport.Refresh();
        }
    }
}


how do i count the desig and show the data in report viewer with the above said query
Posted
Comments
dimpledevani 22-Aug-12 9:16am    
Use summaryFields of Crystal Report

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