结果未设置为变量和会话

时间:2018-04-08 12:59:50

标签: c# asp.net

我正在尝试存储候选人的结果,但它会返回0;没有别的,如果arraylist匹配或不匹配,它将总是增加cot的值,但它会增加cot的值。

请帮助我 - 提前谢谢

public void get_result()
{
    int cot = 0, inc = 0;float final_result=0;
    ArrayList arr = new ArrayList();

    string cs = System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

    SqlConnection con = new SqlConnection(cs);

    SqlCommand cmd = new SqlCommand("(select correct from quiz_question)", con);

    con.Open();

    dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

    for (int j = 0; dr.Read(); j++)
    {
        inc++;
        string ans = dr[0].ToString();
        arr.Add(ans);
        Response.Write(arr.ToString());
    }

    ArrayList arr1 = new ArrayList();
    arr1 = (ArrayList)Session["correct_ans"];

    for(int l = 0; l < inc; l++)
    {
        if(arr[l]!=arr1[l])
        {
            cot++;
        }
    }

    Session["result"] = (Double)((cot/100)*100);

    //final_result = ((cot) / 100);
    //final_result = final_result * 100;
    //Session["result"] = (float)final_result;
    //Response.Write(final_result);
}

0 个答案:

没有答案