title: c# sqlcommand firing twice in the same iteration in foreach loop
body: <p>I am reading the rows from input table and for each row calling an api and inserting the response in the output table. Each row is unique in the input table and so is the api response, but when i write it to the output table the rows are duplicated.Below is the complete code</p>
  
  <pre><code> string sqlconn, sqlquery;
              DataTable datatable = new DataTable();
              public void Main()
              {
                  // TODO: Add your code here
  
                  try
                  {
                      sqlconn = Dts.Variables["User::varSqlconn"].Value.ToString();
                      sqlquery = Dts.Variables["User::varSqlquery"].Value.ToString();
  
                      using (SqlConnection sqlConn = new SqlConnection(sqlconn))
                      {
  
                          using (SqlCommand cmd = new SqlCommand(sqlquery, sqlConn))
                          {
                              SqlDataAdapter da = new SqlDataAdapter(cmd);
                              da.Fill(datatable);
                          }
                      }
                      foreach (DataRow record in datatable.Rows)
                      {
                          APIAddress.CallGoogleAPI((int)record[0], (string)record[1]);
  /*the problem begins here
                          using (SqlConnection connection = new SqlConnection(sqlconn))
                          {
                             if (APIAddress.FORMATTED_ADDRESS != null)
                              {
                                  using (SqlCommand command = new SqlCommand(cmdStr, connection))
                                  {
                                      connection.Open();
                                      command.Parameters.AddWithValue("@ADDR_ID", APIAddress.ADDRESS_ID);
                                      command.Parameters.AddWithValue("@ADDR_ONE", APIAddress.FORMATTED_ADDRESS != null ? APIAddress.FORMATTED_ADDRESS : DBNull.Value.ToString());
                                      command.Parameters.AddWithValue("@POSTALCODE", APIAddress.POSTALCODE_S != null ? APIAddress.POSTALCODE_S : DBNull.Value.ToString());
                                      command.ExecuteNonQuery();
                                      command.Parameters.Clear();
                                  }
                              }
  
                              else
                              {
                              }
                          }
                     }               
                  }
                  catch (Exception ex)
                  {
                      Dts.Events.FireError(0, "ScriptTask", ex.Message, null, 0);
                  }
  </code></pre>