public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { RptBooksReservation rpt = new RptBooksReservation(); rpt.Site = this.Site; return(rpt); }
private void button1_Click(object sender, EventArgs e) { try { RptBooksReservation rpt = new RptBooksReservation(); SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); DataSet myDS = new DataSet(); myConnection = new SqlConnection(cs.DBcon); MyCommand.Connection = myConnection; MyCommand.CommandText = "Select * FROM BookReservation INNER JOIN Book ON BookReservation.AccessionNo = Book.AccessionNo INNER JOIN Employee ON BookReservation.StaffID = Employee.EMPID where R_Date between @d1 and @d2 order by R_Date"; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "Book"); rpt.SetDataSource(myDS); crystalReportViewer1.ReportSource = rpt; Show(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }