private void btnGetData_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; RptStudent rpt = new RptStudent(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); DataSet myDS = new DataSet(); //The DataSet you created. myConnection = new SqlConnection(cs.DBcon); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from Student where student.Session='" + cmbSession.Text + "' and Student.Class = '" + cmbCourse.Text + "' and Student.Section = '" + cmbSection.Text + "'"; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer1.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void getdata() { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; RptStudent rpt = new RptStudent(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); DataSet myDS = new DataSet(); //The DataSet you created. myConnection = new SqlConnection(cs.DBcon); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from Student "; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "Student"); 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() { RptStudent rpt = new RptStudent(); rpt.Site = this.Site; return(rpt); }