我想做的是在一个Crystal Report文件或页面中显示两个表的数据。它带来了字段,但是当我运行查询时,它不会显示报告中的任何数据。 仅供参考,我使用相同的查询从sql server中提取数据以填充GridView,它已经有效。
private void employee_report_Load(object sender, EventArgs e)
{
DAL d = new DAL(); // It is a separte C# class in which i have created connection
d.connect();
d.cmd.CommandText = "SELECT employee.emp_id, employee.first_name, employee.last_name, employee.gender, employee.dob, employee.city, employee.province, employee.phone_number, employee.email, employee.designation, department.department_name FROM department, employee WHERE employee.department_id = department.department_id AND is_deleted = 0";
d.cmd.Connection = d.con;
d.da.SelectCommand = d.cmd;
d.da.Fill(d.dt);
d.disconnect();
ReportDocument rd = new ReportDocument();
rd.FileName = "emp_report.rpt";
rd.SetDataSource(d.dt);
report_employee.ReportSource = rd;
report_employee.Refresh();
}