2017-08-25 10 views
-3

次のコードを使用すると、「getloadDropdownは0引数を取るオーバーロードメソッドがありません」というエラーが発生します。「オーバーロードメソッドに0引数が必要」というエラーが発生するのはなぜですか?

どうすれば解決できますか?私は初心者なので!

親切に助けて感謝:)

ファーストクラス:

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; 
     } 

    } 

セカンドクラス:

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; 

    } 
+0

'obj.getStarDropdown();'あなたは、その署名 'DataTableのgetStarDropdown(int型starID)によると、この方法にstarIDを渡す必要が'それはコンパイラがわかりますものです。 1つのint引数をとるメソッドしかないので、引数を取らないこのメソッドのオーバーロードを見つけることはできません。 – Fildor

答えて

1

2番目のクラスでは、値をdtに設定するときに整数が必要です。

ので

dt = obj.getStarDropdown(PUT AN INTEGER HERE) 
+0

ここにIntegerが何であるかわからないのならリンクです。 https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/int – howells699

1

あなたの関数はint型

/パス整数値のパラメータにを期待します関数、

dt = obj.getStarDropdown(1); 
+0

いくつかの整数は?申し訳ありませんが、私は援助が必要なので@Sajeetharan –

+0

あなたのgetStarDropdownはstarIdを期待して、startIDを渡します – Sajeetharan

関連する問題