Sk Jha

Sk Jha

  • NA
  • 113
  • 43.4k

how to transfer data from datagridview to crystal report.

May 19 2018 10:39 PM
how to transfer data from datagridview to crystal report.
i done this given code but data is not display on crystal report.
 
  1. private void SalesReportPrint_Load(object sender, EventArgs e)  
  2.      {  
  3.          if (con.State == ConnectionState.Open)  
  4.          {  
  5.              con.Close();  
  6.          }  
  7.          con.Open();  
  8.   
  9.          DataSetSalesReport dsr = new DataSetSalesReport();  
  10.          if (from!="" && to != "")  
  11.          {  
  12.              OleDbCommand cmd = new OleDbCommand("SELECT order_item.order_ID, order_user.firstname, order_user.lastname, order_user.billtype, order_user.purchase_date,order_item.barcode, order_item.product, order_item.price, order_item.qty, order_item.discount, order_item.total, order_item.cgst, order_item.sgst FROM order_item right JOIN order_user ON val(order_item.order_id) = order_user.ID where purchase_date between '" + from + "' and '" + to + "'", con);  
  13.              cmd.ExecuteNonQuery();  
  14.              DataTable dt = new DataTable();  
  15.              OleDbDataAdapter da = new OleDbDataAdapter(cmd);  
  16.              da.Fill(dsr.order);  
  17.          }  
  18.          else  
  19.          {  
  20.              OleDbCommand cmd1 = new OleDbCommand("SELECT order_item.order_ID, order_user.firstname, order_user.lastname, order_user.billtype, order_user.purchase_date,order_item.barcode, order_item.product, order_item.price, order_item.qty, order_item.discount, order_item.total, order_item.cgst, order_item.sgst FROM order_item INNER JOIN order_user ON val(order_item.order_id) = order_user.ID;", con);  
  21.              cmd1.ExecuteNonQuery();  
  22.              DataTable dt1 = new DataTable();  
  23.              OleDbDataAdapter da1 = new OleDbDataAdapter(cmd1);  
  24.              da1.Fill(dsr.order);  
  25.          }  
  26.           
  27.   
  28.          CrystalReportSales salesReport = new CrystalReportSales();  
  29.          salesReport.SetDataSource(dsr);  
  30.          salesReport.SetParameterValue("from", from);  
  31.          salesReport.SetParameterValue("to", to);  
  32.          salesReport.SetParameterValue("gtotal", gtotal);  
  33.          crystalReportViewer1.ReportSource = salesReport;  
  34.      }  
  35.  }  
 
 

Answers (1)