Solved

No overload for method ...

Posted on 2004-09-11
1
1,826 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

635 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