?
Solved

No overload for method ...

Posted on 2004-09-11
1
Medium Priority
?
1,828 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

719 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