private void frmCustomersReport_Load(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptCustomers rpt = new rptCustomers(); //The report you created. cmd = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); RMS_DBDataSet myDS = new RMS_DBDataSet(); //The DataSet you created. con = new SqlConnection(cs.DBConn); cmd.Connection = con; cmd.CommandText = "SELECT * from Customer order by CustomerName"; cmd.CommandType = CommandType.Text; myDA.SelectCommand = cmd; myDA.Fill(myDS, "Customer"); rpt.SetDataSource(myDS); crystalReportViewer1.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { rptCustomers rpt = new rptCustomers(); rpt.Site = this.Site; return rpt; }