-3

I get "no overload method 'getStarDropdown' takes 0 arguments" error using the following code.

How can i resolve this? As i am a newbie!

Kindly help thanks :)

First Class :

public DataTable getStarDropdown(int starID)
    {
        try
        {
            DataTable dtStar = null;
            CommonDAL obj = new CommonDAL();
            DataSet dsAll = obj.getStarEntity(starID);

            if (dsAll != null)
                dtStar = dsAll.Tables[1];
            return dtStar;
        }
        catch (Exception ex)
        {
            string msg = ex.Message;

            ExceptionLogger.WriteToLog(hostWebUrl, "CommonDAL", "getAllDropDown()", ex.Message, ex.StackTrace, ExceptionLogger.LOGTYPE.ERROR.ToString());
            return null;
        }

    }

Second Class :

public static List<Dictionary<string, object>> GetStarData()
    {
        CommonBAL obj = new CommonBAL();
        DataTable dt = new DataTable();
        dt = obj.getStarDropdown();

        System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
        List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
        Dictionary<string, object> row;
        foreach (DataRow dr in dt.Rows)
        {
            row = new Dictionary<string, object>();
            foreach (DataColumn col in dt.Columns)
            {
                row.Add(col.ColumnName, dr[col]);
            }
            rows.Add(row);
        }
        return rows;

    }
Sanjana V
  • 125
  • 1
  • 3
  • 11
  • `obj.getStarDropdown();` you need to pass a starID to this method according to its signature `DataTable getStarDropdown(int starID)` that's what the compiler tells you. It cannot find an overload of this method that takes no arguments because there is only the one that take one int argument. – Fildor Aug 25 '17 at 10:05

2 Answers2

1

Your function expects a parameter of type int

/pass integer value to the function,

 dt = obj.getStarDropdown(1);
Fildor
  • 14,510
  • 4
  • 35
  • 67
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
1

In the second class, an integer is required when setting a value to dt.

So

dt = obj.getStarDropdown(PUT AN INTEGER HERE)
howells699
  • 148
  • 14
  • If you don't know what an Integer is here is a link. https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/int – howells699 Aug 25 '17 at 10:10