locked
Binding a Data Table or a Data set to a crystal Report RRS feed

  • Question

  • User-59737300 posted

    Please Help....!!

    string sql = "SELECT personal_infrmation1.PIM_ADD1, personal_infrmation1.PIM_ADD2, personal_infrmation1.PIM_AREA, personal_infrmation1.PIM_PINCODE, personal_infrmation1.PIM_CITY, personal_infrmation1.PIM_DESIG_DESC, emp_payout1.PAY_CTC, personal_infrmation1.PIM_DOJ, emp_payout1.PAY_BASIC, emp_payout1.PAY_HRA, emp_payout1.PAY_CCA, emp_payout1.PAY_CONV, emp_payout1.PAY_SPLALL, emp_payout1.PAY_GROSS, emp_payout1.PAY_PF_AMT, personal_infrmation1.PIM_BAND_DESC, personal_infrmation1.PIM_GRADE_DESC, personal_infrmation1.PIM_DEPT_DESC, personal_infrmation1.PIM_ID_NO, personal_infrmation1.PIM_MID_NM, personal_infrmation1.PIM_FST_NM, personal_infrmation1.PIM_LST_NM, personal_infrmation1.PIM_STATE, personal_infrmation1.PIM_COUNTRY FROM   shbhrm.personal_infrmation personal_infrmation1 INNER JOIN shbhrm.emp_payout emp_payout1 ON personal_infrmation1.PIM_ID_NO = emp_payout1.PAY_PIM_ID_NUMBER AND personal_infrmation1.PIM_ID_NO =" + txtEmpNo.Text;
                using (MySqlConnection conn = new MySqlConnection(connStr))
                {
                    using (MySqlCommand cmnd = new MySqlCommand(sql, conn))
                    {
                        conn.Open();
                        using (MySqlDataAdapter da = new MySqlDataAdapter(cmnd))
                        {
                            dt = new DataTable("tb1");
                            da.Fill(dt);
                        }
                    }
                }
                ReportDocument doc = new ReportDocument();
                string reportpath = Server.MapPath("Reports/Offrltr.rpt");
                doc.Load(reportpath);
                doc.SetDataSource(dt);
                CrystalReportViewer1.ReportSource = doc;

    Mention Above is the code for binding the data to the Crystal report dynamically. But what problem i face is i am getting all records Instead of fetching a single record

    Tuesday, March 6, 2012 6:11 AM

All replies