You must Sign In to post a response.
  • Category: .NET

    Unable to trace the set value of "yahr" value in the given codebase.

    Hi Team,
    Can you assist me on this issue


    private IList getRatingByYear(string y)
    {
    if(y == null || y.Equals("")) return null;

    IList result = new ArrayList();

    String strQuery = "SELECT rating_id, prefix, sparp, risik, yahr FROM Rating WHERE yahr='{0}' order by prefix";
    strQuery = String.Format(strQuery, y);

    string connectionString = ConfigurationSettings.AppSettings["ConnectionString"];

    SqlConnection conn = new SqlConnection(connectionString);
    try
    {
    SqlCommand cmd = new SqlCommand(strQuery, conn);
    conn.Open();
    SqlDataReader reader = cmd.ExecuteReader();
    while(reader.Read())
    {
    ZurichNS.Data.RatingLine rl = new ZurichNS.Data.RatingLine();

    rl.ID = (int)reader["rating_id"];
    rl.Prefix = (string)reader.GetString(1);//["prefix"];
    rl.Yahr = (String)reader["yahr"] ;
    rl.Sparp = System.Double.Parse(reader["sparp"].ToString());
    rl.Risik = System.Double.Parse(reader["risik"].ToString());


    result.Add(rl);
    }
    reader.Close();
    }
    finally
    {
    if(conn != null)
    {
    conn.Close();
    conn.Dispose();
    }
    }
    return result;
    }
  • #761327
    Hai Shashi,
    The error message is correct as per the code you have written "Unable to trace the set value of "yahr" value in the given codebase."
    Now look the code which you are using:

    if(y == null || y.Equals("")) return null;

    You can see that if the value of y is null then return null.
    Instead you can check:

    string.IsNullOrEmpty(y) return null;

    Hope you can solve your issue.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com


Sign In to post your comments