private void frmTransportationReport_Load(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptTransportation rpt = new rptTransportation(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); StudentDataSet myDS = new StudentDataSet(); //The DataSet you created. Transportation_DBDataSet frm = new Transportation_DBDataSet(); myConnection = new SqlConnection("Data Source=GHAFFARI\\ALIGHAFFARI;Initial Catalog=CMS;Integrated Security=True;"); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from transportation order by SourceLocation"; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "Transportation"); 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() { rptTransportation rpt = new rptTransportation(); rpt.Site = this.Site; return(rpt); }