private void txtHostelName_TextChanged(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; RptHostelers rpt = new RptHostelers(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); ERPS_DBDataSet myDS = new ERPS_DBDataSet(); //The DataSet you created. myConnection = new SqlConnection(cs.DBcon); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from Hosteler,Student where Student.AdmissionNo=Hosteler.AdmissionNo and hostelname Like '" + txtHostelName.Text + "%' order by Studentname "; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "Hosteler"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer5.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { RptHostelers rpt = new RptHostelers(); rpt.Site = this.Site; return(rpt); }
private void button2_Click(object sender, EventArgs e) { try { if (cmbClass.Text == "") { MessageBox.Show("Please select class", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbClass.Focus(); return; } if (cmbSection.Text == "") { MessageBox.Show("Please select Section", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbSection.Focus(); return; } Cursor = Cursors.WaitCursor; timer1.Enabled = true; RptHostelers rpt = new RptHostelers(); //The report you created. SqlConnection myConnection = default(SqlConnection); SqlCommand MyCommand = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); ERPS_DBDataSet myDS = new ERPS_DBDataSet(); //The DataSet you created. myConnection = new SqlConnection(cs.DBcon); MyCommand.Connection = myConnection; MyCommand.CommandText = "select * from Hosteler,Student where Student.AdmissionNo=Hosteler.AdmissionNo and JoiningDate between @date1 and @date2 and Class= '" + cmbClass.Text + "'and Section='" + cmbSection.Text + "' order by Studentname "; MyCommand.Parameters.Add("@date1", SqlDbType.DateTime, 30, "JoiningDate").Value = Date_from.Value.Date; MyCommand.Parameters.Add("@date2", SqlDbType.DateTime, 30, "JoiningDate").Value = Date_to.Value.Date; MyCommand.CommandType = CommandType.Text; myDA.SelectCommand = MyCommand; myDA.Fill(myDS, "Hosteler"); myDA.Fill(myDS, "Student"); rpt.SetDataSource(myDS); crystalReportViewer1.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }