Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Error in compiling Page with Crystal reports

Error in compiling Page with Crystal reports

Scheduled Pinned Locked Moved ASP.NET
helpvisual-studioquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    www Developerof NET
    wrote on last edited by
    #1

    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.

    A 1 Reply Last reply
    0
    • W www Developerof NET

      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.

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      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

      W 1 Reply Last reply
      0
      • A Abhishek Sur

        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

        W Offline
        W Offline
        www Developerof NET
        wrote on last edited by
        #3

        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.

        A 1 Reply Last reply
        0
        • W www Developerof NET

          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.

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups