Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

No overload for method ...

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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

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…
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
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

926 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