Error in compiling Page with Crystal reports
-
Hi all, Following is my code for setting the data source for a cystal report which i m using in my project. protected void DDL_Departments_SelectedIndexChanged(object sender, EventArgs e) { int deptid=int.Parse(DDL_Departments.SelectedValue); EmployeesTableAdapters.Get_Employee_By_Department _emp_adapter=new EmployeesTableAdapters.Get_Employee_By_Department(); Employees.EmployeesDataTable _emp; _emp=_emp_adapter.Get_Employees_By_Dept(deptid); _rdc.SetDataSource(_emp); CR_Emp_Viewer.ReportSource=_rdc; CR_Emp_Viewer.DataBind(); } but its giving me a compile time error stating
CS0121: The call is ambiguous between the following methods or properties: 'CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(System.Collections.IEnumerable)' and
'CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(System.Data.DataTable)'What do i need to do to solve this issue????
Also its surprising that a similar code i wrote in VB runs successfully.:confused::confused::confused:
I am using VS 2005, 2.0 framework.
When you fail to plan, you are planning to fail.
-
Hi all, Following is my code for setting the data source for a cystal report which i m using in my project. protected void DDL_Departments_SelectedIndexChanged(object sender, EventArgs e) { int deptid=int.Parse(DDL_Departments.SelectedValue); EmployeesTableAdapters.Get_Employee_By_Department _emp_adapter=new EmployeesTableAdapters.Get_Employee_By_Department(); Employees.EmployeesDataTable _emp; _emp=_emp_adapter.Get_Employees_By_Dept(deptid); _rdc.SetDataSource(_emp); CR_Emp_Viewer.ReportSource=_rdc; CR_Emp_Viewer.DataBind(); } but its giving me a compile time error stating
CS0121: The call is ambiguous between the following methods or properties: 'CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(System.Collections.IEnumerable)' and
'CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(System.Data.DataTable)'What do i need to do to solve this issue????
Also its surprising that a similar code i wrote in VB runs successfully.:confused::confused::confused:
I am using VS 2005, 2.0 framework.
When you fail to plan, you are planning to fail.
I believe reportdatasource(_rdc) expects IEnumerable Collection, while you are passing DataTable, which is not an IEnumerable Collection. So it throws the error. If you are in 3.5, you can call DataTable.asEnumerable() here you need to pass _emp.Rows collection which is IEnumerable collection. Try out this. I have never found this before, Hope it works.
Abhishek Sur My Latest Articles Working with Excel using MDAC
Basics on LINQ and Lambda Expressions
Create .NET Templates -
I believe reportdatasource(_rdc) expects IEnumerable Collection, while you are passing DataTable, which is not an IEnumerable Collection. So it throws the error. If you are in 3.5, you can call DataTable.asEnumerable() here you need to pass _emp.Rows collection which is IEnumerable collection. Try out this. I have never found this before, Hope it works.
Abhishek Sur My Latest Articles Working with Excel using MDAC
Basics on LINQ and Lambda Expressions
Create .NET TemplatesAbhishek Sur wrote:
I believe reportdatasource(_rdc) expects IEnumerable Collection, while you are passing DataTable, which is not an IEnumerable Collection. So it throws the error.
But SetDataSource provides four overloads from which one does accepts a DataTable. I am pretty confused as to why it recognises the data table as an IEnumerable.:confused::confused:
When you fail to plan, you are planning to fail.
-
Abhishek Sur wrote:
I believe reportdatasource(_rdc) expects IEnumerable Collection, while you are passing DataTable, which is not an IEnumerable Collection. So it throws the error.
But SetDataSource provides four overloads from which one does accepts a DataTable. I am pretty confused as to why it recognises the data table as an IEnumerable.:confused::confused:
When you fail to plan, you are planning to fail.
this is weird. Try to do this, and see if it works or not:
Employees.EmployeesDataTable _emp;
_emp=_emp_adapter.Get_Employees_By_Dept(deptid);
DataTable dt = _emp.Table;
_rdc.SetDataSource(dt);Pass the Table to the SetDataSource rather than your class.:thumbsup:
Abhishek Sur My Latest Articles Working with Excel using MDAC
Basics on LINQ and Lambda Expressions
Create .NET Templates