Im creating payslip report using rdlc file in c#, asp.net. Im populating values from two tables for a single rdlc file. In My Dataset1.xsd file, i have to two tables as salary and employee. Im getting informations from both table and adding it to report. I followed below table but all values in report shows as
Error
When i populating one table then it works fine. What im doing wrong? If the below code is wrong method,please guide me. For previous projects , i used rdlc.But multiple datasets for multiple tables.
protected void GetPayslipReport(string employeename)
{
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Payslip.rdlc");
ReportViewer1.LocalReport.DataSources.Clear();
int Empid = 0;
string sQuery;
sQuery = "SELECT * FROM salary WHERE (EmployeeName ='" + employeename + "'AND month='" + UserMonthList.SelectedItem.ToString() + "'AND Year ='" + UserYearList.SelectedItem.ToString() + "')";
MySqlDataAdapter ada = new MySqlDataAdapter(sQuery, GlobalCS.objMyCon);
DataSet ds = new DataSet();
ada.Fill(ds);
ReportDataSource reportDataSource = new ReportDataSource();
reportDataSource.Name = "DataSet1_salary";
reportDataSource.Value = ds.Tables[0];
ReportViewer1.LocalReport.DataSources.Add(reportDataSource);
/*To get EmpID */
sQuery = "SELECT EmpID FROM employee WHERE (EmployeeName ='" + employeename + "')";
MySqlCommand command = new MySqlCommand(sQuery, GlobalCS.objMyCon);
MySqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Empid = reader.GetInt32("EmpID");
}
reader.Close();
/***/
sQuery = "SELECT * FROM employee WHERE EmpID =" + Empid;
MySqlDataAdapter ada2 = new MySqlDataAdapter(sQuery, GlobalCS.objMyCon);
DataSet ds2 = new DataSet();
ada2.Fill(ds2);
ReportDataSource reportDataSource2 = new ReportDataSource();
reportDataSource2.Name = "DataSet1_employee";
reportDataSource2.Value = ds2.Tables[0];
ReportViewer1.LocalReport.DataSources.Add(reportDataSource2);
}