Solved

No overload for method ...

Posted on 2004-09-11
1
1,823 Views
Last Modified: 2012-08-14
Here's the error:

 Compiler Error Message: CS1501: No overload for method 'gettheitems' takes '6' arguments

Source Error:

Line 42:
Line 43:              IBuySpy.ProductsDB1 productlist = new IBuySpy.ProductsDB1();
Line 44:              MyList.DataSource = productlist.gettheitems(color, category, year, region, appellation, country);
Line 45:              MyList.DataBind();
Line 46:          }

It works fine if I leave the country paramter off. Here's the ASP that sets the paramter values:

void makeselection_Click(Object sender, System.EventArgs e) {
     string col;
     string cat;
     string yea;
     string reg;
     string cou;
     string app;
col = color.SelectedItem.Text;
          if (col!="") {
          Session["color"] = color.SelectedItem.Text;
          }
          else {
          Session["color"] = "";
          }
         
     cat = category.SelectedItem.Text;    
          if (cat!="") {
          Session["category"] = category.SelectedItem.Text;
          }
          else {
          Session["category"] = "";
          }
     yea = year.SelectedItem.Text;
          if (yea!="") {
          Session["year"] = year.SelectedItem.Text;
          }    
         else {
          Session["year"] = "";
          }
     reg = region.SelectedItem.Text;
          if (reg!="") {
          Session["region"] = region.SelectedItem.Text;
          }    
          else {
          Session["region"] = "";
          }
     cou = country.SelectedItem.Text;
          if (cou!="") {
          Session["country"] = country.SelectedItem.Text;
          }    
          else {
          Session["country"] = "";
          }
     app = appellation.SelectedItem.Text;
          if (app!="") {
           Session["appellation"] = appellation.SelectedItem.Text;
           
          }
          else {
           Session["appellation"] = "";
          }
               
         
               Response.Redirect("winelist.aspx");
---------------------------------------------------------------------------
WINELIST.ASPX

void Page_Load(Object sender, EventArgs e) {

        string color = Session["color"].ToString();
     string category = Session["category"].ToString();
     string year = Session["year"].ToString();
        string region = Session["region"].ToString();
     string appellation = Session["appellation"].ToString();
     string country = Session["country"].ToString();

             IBuySpy.ProductsDB1 productlist = new IBuySpy.ProductsDB1();
             MyList.DataSource = productlist.gettheitems(color, category, year, region, appellation, country);
             MyList.DataBind();

-----------------------------------------------------------------------------------------------------------------------------
METHOD

public SqlDataReader gettheitems(string color, string category, string year, string region, string appellation, string country) {


        SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
            SqlCommand myCommand = new SqlCommand("getwinelist3", myConnection);

            // Mark the Command as a SPROC
            myCommand.CommandType = CommandType.StoredProcedure;

            SqlParameter parametercategory = new SqlParameter("@category", SqlDbType.NVarChar, 4000);
            parametercategory.Value = category;
            myCommand.Parameters.Add(parametercategory);

SqlParameter parametercolor = new SqlParameter("@color", SqlDbType.NVarChar, 4000);
            parametercolor.Value = color;
            myCommand.Parameters.Add(parametercolor);
               
SqlParameter parameteritemdid1 = new SqlParameter("@itemdid1", SqlDbType.NVarChar, 4000);
            parameteritemdid1.Direction = ParameterDirection.Output;
            myCommand.Parameters.Add(parameteritemdid1);          
                     
SqlParameter parameteryear = new SqlParameter("@year", SqlDbType.NVarChar, 4000);
            parameteryear.Value = year;
            myCommand.Parameters.Add(parameteryear);

    SqlParameter parameterregion = new SqlParameter("@region", SqlDbType.NVarChar, 4000);
            parameterregion.Value = region;
            myCommand.Parameters.Add(parameterregion);

    SqlParameter parameterapp = new SqlParameter("@appellation", SqlDbType.NVarChar, 4000);
            parameterapp.Value = appellation;
            myCommand.Parameters.Add(parameterapp);

 SqlParameter parametercountry = new SqlParameter("@country", SqlDbType.NVarChar, 4000);
            parameterapp.Value = country;
            myCommand.Parameters.Add(parametercountry);

 myConnection.Open();
            SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
               return result;

      }


and just in case your curious, here's my stored proc:

CREATE PROCEDURE getwinelist3
(
@color nvarchar(50),
@category nvarchar(50),
@year nvarchar(50),
@region nvarchar(50),
@appellation nvarchar(50),
@country nvarchar(50),
@itemdid1 nvarchar(50) OUTPUT  
)
AS
SELECT ltrim(rtrim(name1)) as name1,  ltrim(rtrim(bottleprice)) as bottleprice, ltrim(rtrim(caseprice)) as caseprice, ltrim(rtrim(vintage)) as year, itemdid1
FROM   newtable
WHERE
region like '%' + ISNULL(@region, '') + '%'  AND
color like '%' + ISNULL(@color, '') + '%'  AND
category like '%' + ISNULL(@category, '') + '%'  AND
vintage like '%' + ISNULL(@year, '') + '%'  AND
appelation like '%' + ISNULL(@appellation, '' ) + '%'  AND
 country like '%' + ISNULL(@country, '') + '%'
GO
0
Comment
Question by:dprasad
1 Comment
 
LVL 13

Accepted Solution

by:
BlackTigerX earned 500 total points
ID: 12036590
well, you have the problem and the solution

MyList.DataSource = productlist.gettheitems(color, category, year, region, appellation, country);

the overload methods (as you may already know) are the same method but with different number of parameters and/or type, in this case, NONE of the overload methods can take 6 parameters, there is no overloaded method that will take 6 parameters

now, I see  you have this line:

public SqlDataReader gettheitems(string color, string category, string year, string region, string appellation, string country) {

but is that part of the IBuySpy.ProductsDB1 class?
or is that a method you declared in YOUR class?

if YOU defined that method in YOUR class, then the only problem is that you are calling it like

productlist.gettheitems(color, category, year, region, appellation, country);

you would need to call it like:

gettheitems(color, category, year, region, appellation, country);
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question