Form
frmMysalary
private void print_Click(object sender, EventArgs e)
{
datatable tbl= new datatable();
SqlDataAdapter adp = new SqlDataAdapter("select * from staffdetails where staffID='"+textbox1.text+"'",conn);
adp.fill(tbl);
if(dt>0)
{
Reports.StaffReport sr = new Reports.StaffReport ();
sr.dt = tbl;
sr.Show();
}
else
{
MessageBox.Show("No Records found");
}
}
Form
StaffReport
public DataTable dt = new DataTable();
private void crystalReportViewer1_Load(object sender, EventArgs e)
{
Reports.StaffReport crt = new Reports.StaffReport();
crt.Database.Tables[0].SetDataSource(dt);
crystalReportViewer1.ReportSource = crt;
}