execute non query not working
<p>I am trying to add new values to database but executenonquery is not working. I have tested and realized that just after executing non query, the system stops working. In short, it does not fire. There is no error returned. Here is the code:</p>

<pre><code>else
{
    double amounts = Convert.ToDouble(InstallmentPaidBox.Text);
    string date = period.Text;
    SqlCommand a = new SqlCommand("Select top 1* from Minimum_Amount order by Period desc", con);
    con.Open();
    SqlDataReader sq = a.ExecuteReader();

    while (sq.Read())
    {
        string date2 = sq["Period"].ToString();
        double amount = Convert.ToDouble(sq["Amount"]);
        double areas = amount - (Convert.ToDouble(InstallmentPaidBox.Text) + Convert.ToDouble(BalanceBroughtTextBox.Text));
        double forwarded = Convert.ToDouble(BalanceBroughtTextBox.Text) + Convert.ToDouble(InstallmentPaidBox.Text);
        double balance = areas;
         SqlCommand cmd = new SqlCommand("insert into Cash_Position(Member_No,Welfare_Amount, BFWD,Amount,Installment_Paid,Loan_Repayment,Principal_Paid,Loan_Balance,Interest_Paid,Interest_Due,Penalty_Paid,Penalty_Due,Installment_Arrears,CFWD,Balance_Due,Period,Date_Prepared,Prepared_By) values(@a,@b,@c,@d,@e,@f,@g,@h,@i,@j,@k,@l,@m,@n,@o,@x,@p,@q)", con);
        cmd.Parameters.Add("@a", SqlDbType.NChar).Value = MemberNumberTextBox.Text;
        cmd.Parameters.Add("@b", SqlDbType.Money).Value = WelfareAmount.Text;
        cmd.Parameters.Add("@c", SqlDbType.Money).Value = BalanceBroughtTextBox.Text;
        cmd.Parameters.Add("@d", SqlDbType.Money).Value = amounts;
        cmd.Parameters.Add("@e", SqlDbType.Money).Value = InstallmentPaidBox.Text;
        cmd.Parameters.Add("@f", SqlDbType.Money).Value = 0;
        cmd.Parameters.Add("@g", SqlDbType.Money).Value = PrincipalPaid.Text;
        cmd.Parameters.Add("@h", SqlDbType.Money).Value = 0;
        cmd.Parameters.Add("@i", SqlDbType.Money).Value = InterestPaid.Text;
        cmd.Parameters.Add("@j", SqlDbType.Money).Value = 0;
        cmd.Parameters.Add("@k", SqlDbType.Money).Value = PenaltyPaid.Text;
        cmd.Parameters.Add("@l", SqlDbType.Money).Value = 0;
        cmd.Parameters.Add("@m", SqlDbType.Money).Value = areas;
        cmd.Parameters.Add("@n", SqlDbType.Money).Value = forwarded;
        cmd.Parameters.Add("@o", SqlDbType.Money).Value = balance;
        cmd.Parameters.Add("@x", SqlDbType.NChar).Value = period.Text;
        cmd.Parameters.Add("@p", SqlDbType.Date).Value = dateOf.Text;
        cmd.Parameters.Add("@q", SqlDbType.VarChar).Value = prepared.Text;

        int rows = cmd.ExecuteNonQuery();

        if (rows &gt; 0)
        {
            string script = "&lt;script&gt;alert('Data Successfully Added')&lt;/script&gt;";
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Added", script);
        }
        else
        {
            string script = "&lt;script&gt;alert('Error Adding Data')&lt;/script&gt;";
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Error", script);
        }
    }
    con.Close();
}
</code></pre>
