0
Reply

crystal report not working in wpf

Hardik Patel

Hardik Patel

Oct 30 2013 1:18 AM
784
i try to generate crystal report based on dataset. i got the dataset but not able to display it on crystal report. i am using below code




 public static ReportDS ResultDS = new ReportDS();
        public winReport(DataSet ds)
        {
            
          InitializeComponent();         
             
          ReportDocument report = new ReportDocument();
          ResultDS = new ReportDS();
          DataRow dr;
          dr = ResultDS.Tables["ResultDT"].NewRow();
          ResultDS.Tables["ResultDT"].Rows.Add(dr);
          for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
          {
              for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
              {
                  if ((ds.Tables[0].Rows[j][i].ToString() != "") && (ds.Tables[0].Rows[j][i].ToString() != "\n\r\t") && (ds.Tables[0].Rows[j][i].ToString().Length!=0))
                  {
                      ResultDS.Tables["ResultDT"].Rows[0][i] = ds.Tables[0].Rows[j][i].ToString();
                  }
              }
          }
          string reportPath = System.AppDomain.CurrentDomain.BaseDirectory + "Reports\\PRS.rpt";
           report.Load(reportPath);
           
       
           report.SetDataSource(ds);
           CRViewer.ViewerCore.ReportSource = report;