executenonquery not working in for loop
<p>In database:</p>

<pre><code>Alter Procedure Update_MaterialTransactionsto2ForWithdrawal
  @materialName varchar(50),
  @staffNumber varchar(10),
  @description varchar(50),
  @transactionID int
As
Begin
   Update Table_MaterialTransactions
   set Status=2
   where StaffNumber = @staffNumber 
     and CrossSection = @description 
     and SubSubCategory = @materialName 
     and Status = 1 
     and TransactionID = @transactionID
End
</code></pre>

<p>In data access layer:</p>

<pre><code>public static void UpdateMaterial(string staffNumber,string materialName,string description,int transaction)
{
    SqlConnection connection = new SqlConnection(ConnectDatabase.ReturnConnectionString());
    //I am passing connection string as the parameter

    try
    {
        connection.Open();
        SqlCommand cmd = new SqlCommand("Update_MaterialTransactionsto2ForWithdrawal", connection);

        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Clear();
        cmd.Parameters.Add("@materialName", SqlDbType.Varchar, 50).Value = materialName;
        cmd.Parameters.Add("@staffNumber", SqlDbType.Varchar, 50).Value = staffNumber;
        cmd.Parameters.Add("@description", SqlDbType.Varchar, 50).Value = description;
        cmd.Parameters.Add("@transactionID", SqlDbTypeInt).Value = transactionID;

        int i = cmd.ExecuteNonQuery();

        connection.Close();
    }
    catch(Exception ex)
    {
       connection.Close();
    }
</code></pre>

<p>On the client side:</p>

<pre><code>void btnSubmit_Click(Object sender,EventArgs e)
{
   int j=0,k=0;

   for(int i=0;i&lt;transactions.Count;i++)
   {
       string id = "ctl00$ContentPlaceHolder1$" + i.ToString();

       CheckBox chk=(CheckBox)Page.FindControl(id);

       if(chk.Checked == true)
       {
            Objects.UpdateMaterial(staffNumbers[i].ToString(), materials[i].ToString(), descriptions[i].ToString(), Convert.ToInt32(transactions[i]));

            j++;
       }
       else
       {
            Objects.DeleteTheSelectedRowOfMaterialTransaction(staffNumbers[i].ToString(), materials[i].ToString(), descriptions[i].ToString(), Convert.ToInt32(transactions[i]));

            k++;
        }
   }
</code></pre>

<p>I have check boxes in the table and when the user checks the check boxes and clicks submit, the boxes which are checked will update the database.</p>

<p>But the <code>cmd.ExecuteNonQuery()</code> is not executing and it is returning 0 rows. It is not throwing any error. But if I do this manually in the database, the stored procedure is working fine.</p>

<p>Kindly tell me where I am going wrong.</p>
