Solved

No overload for method ...

Posted on 2004-09-11
1
1,818 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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
c# code 19 56
Why, and when, to use Windows Workflow 1 16
Trouble with References... 5 21
Long URL in SMS 6 22
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now