Click here to Skip to main content
15,878,970 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
CS0121: The call is ambiguous between the following methods or properties: 'Microsoft.Reporting.WebForms.ReportDataSource.ReportDataSource(string, System.Data.DataTable)' and 'Microsoft.Reporting.WebForms.ReportDataSource.ReportDataSource(string, System.Collections.IEnumerable)'

I used VS2010 and report.rdlc in my application. I created dataset... because here, the report data are used to dataset on report design view. How can I configure it.......???

C#
protected void btnShowReport_Click(object sender, EventArgs e)
    {
        try
        {
            int Language;
            string ReportPath, QueryParams, Query, QueryHeader, LanguagePostFlix;

            string MyCulture = Session["MyCulture"].ToString();

            QueryParams = ddlWard.SelectedValue; // +",";
            if (MyCulture == "en-GB")
            {
                Language = 1;
                LanguagePostFlix = "English.rdlc";
            }
            else
            {
                Language = 2;
                LanguagePostFlix = "Hindi.rdlc";
            }
            QueryParams += "," + Language.ToString();

            if (txtHouseNo.Text != string.Empty)
                QueryParams += "," + txtHouseNo.Text.Trim();
            else
                QueryParams += "," + "-1";

            if (txtFamilyHeadName.Text != string.Empty)
                QueryParams += "," + txtFamilyHeadName.Text.Trim();
                //QueryParams += "," + 
                //float.Parse(txtFamilyHeadName.Text.Trim());
            else
                QueryParams += "," + "-1";
  
            QueryHeader = "Exec spGetHeader '" + MyCulture + "'";

            SqlDataAdapter daHeader = 
                           new SqlDataAdapter(QueryHeader, strconstring);
            dsPRReport.spGetHeaderDataTable dtHeader = 
                       new dsPRReport.spGetHeaderDataTable();
            //DataSet1. dtHeader = new dsPRReport.spGetHeaderDataTable();

            daHeader.Fill(dtHeader);
            Query = "Exec spPRReport" + QueryParams;

            SqlDataAdapter da = new SqlDataAdapter(Query, strconstring);
            dsPRReport.spPRReportDataTable dt = 
                             new dsPRReport.spPRReportDataTable();

            //Error Show here and go to Exception..... Incorrect syntax near ','. 
            da.Fill(dt);

            ReportPath = @"Reports\PRReport" + LanguagePostFlix;
            ReportViewer1.LocalReport.ReportPath = Server.MapPath(ReportPath);

            ReportParameter[] Params = new ReportParameter[3];
            Params[0] = new ReportParameter
                        ("WardID", ddlWard.SelectedItem.Text.Trim());
            Params[1] = new ReportParameter("HouseNo", txtHouseNo.Text.Trim());
            Params[2] = new ReportParameter("FamilyHeadName",
                        txtFamilyHeadName.Text.Trim());
            ReportViewer1.LocalReport.SetParameters(Params);
        
            ReportDataSource dsHeader = 
                         new ReportDataSource("dsPRReport_spGetHeader");
            ReportDataSource ds = 
                         new ReportDataSource("dsPRReport_spPRReport");

            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(dsHeader);
            ReportViewer1.LocalReport.DataSources.Add(ds);            

            ReportViewer1.LocalReport.Refresh();
        }

        catch (Exception ex) 
              { lblMessage.Text = ex.Message; lblMessage.Visible = true; }
    }
Posted
Updated 25-Jan-22 2:56am
v5

I looks the PRReport.spPRReportDataTable is neither a DataTable nor a IEnumerable, hence you cannot call ReportDataSource ctor passing it as second argument. If you are sure it can be casted into one of them (in a DataTable, I suppose :-) ) then you might explicitely cast it on the method call.
 
Share this answer
 
Comments
Faizymca 5-Jun-13 1:11am    
Sir, Yes Second Agument cann't passed but here now come to another error.....Incorrect syntax near ','.
Faizymca 5-Jun-13 1:14am    
i checkout my spPRReport ....not able to find the error so help pls ....sir
my sp this type


ALTER PROCEDURE [dbo].[spPRReport]
@WardID int,
@Language int,
@HouseNo varchar(50),
@FamilyHeadName varchar(50)

AS
BEGIN
IF (@HouseNo<>'' AND @FamilyHeadName='')
BEGIN
SELECT WardNoHindi,MohallaNameHindi,HouseNo,SerialNo,FamilyHeadName,MemberName,FatherHusbandName,SexNameHindi,DateOfBirth,Age,OccupationNameHindi,QualificationNameHindi,RegistrationDate FROM vwSearchFamilyHead
WHERE HouseNo=@HouseNo AND WardID=@WardID
END
ELSE IF (@FamilyHeadName<>'' AND @HouseNo='')
BEGIN
SELECT WardNoHindi,MohallaNameHindi,HouseNo,SerialNo,FamilyHeadName,MemberName,FatherHusbandName,SexNameHindi,DateOfBirth,Age,OccupationNameHindi,QualificationNameHindi,RegistrationDate FROM vwSearchFamilyHead
WHERE FamilyHeadName=@FamilyHeadName AND WardID=@WardID
END
ELSE IF (@HouseNo<>'' AND @FamilyHeadName<>'')
BEGIN
SELECT WardNoHindi,MohallaNameHindi,HouseNo,SerialNo,FamilyHeadName,MemberName,FatherHusbandName,SexNameHindi,DateOfBirth,Age,OccupationNameHindi,QualificationNameHindi,RegistrationDate,[Language] FROM vwSearchFamilyHead
WHERE HouseNo=@HouseNo AND FamilyHeadName=@FamilyHeadName
AND WardID=@WardID AND [Language]=@Language
END

END
Yes Sir, you are right, but I am new to VS 2010, so do not know about configure in Report data.
My Report Data display adds dataset... I did change the name of DataSet in this dsPRReport but can't change... how can I see this type?

dsPRReport_spGetHeaderTableAdapter
and dsPRReport.spPRReportTableAdapter

Sir, if possible, please give a step by step example...

C#
QueryHeader = "Exec spGetHeader '" + MyCulture + "'";

            SqlDataAdapter daHeader = 
                       new SqlDataAdapter(QueryHeader, strconstring);

            dsPRReport.spGetHeaderTableAdapter dtHeader = 
                       new dsPRReport.spGetHeaderTableAdapter();
           
            daHeader.Fill(dtHeader);
            Query = "Exec spPRReport" + QueryParams;

            SqlDataAdapter da = new SqlDataAdapter(Query, strconstring);
            dsPRReport.spPRReportTableAdapter dt = 
                       new dsPRReport.spPRReportTableAdapter();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900