Question: I have the following problem when inserting the info in the databases

```
public void Insertar()
{
   SqlConnection con = new SqlConnection();
   con.ConnectionString = "Data Source=BD-DLLO-SP2016;Initial Catalog=GobernacionCesar;Integrated Security=True";

   con.Open();

   string query = "INSERT INTO Liquidacion (IdLiquidacion, IdPeriodo, FechaGeneracion, Usuario) VALUES(@IdLiquidacion, @IdPeriodo, @FechaGeneracion, @Usuario)";

   SqlCommand com1 = new SqlCommand(query, con);

   foreach (GridViewRow gridRow in GridView4.Rows)
   {
       Iniciar();
       com1.Parameters.AddWithValue("@IdLiquidacion", A);
       com1.Parameters.AddWithValue("@IdPeriodo", cell);
       com1.Parameters.AddWithValue("@FechaGeneracion", DateTime.Now.ToString());
       com1.Parameters.AddWithValue("@Usuario", gridRow.Cells[0].Text);

       com1.ExecuteNonQuery();
   }

   con.Close();
   return;
}

```

Answer: 
Move the command

```
SqlCommand com1 = new SqlCommand(query, con);

```

to the beginning of the loop:

```
foreach (GridViewRow gridRow in GridView4.Rows)
{
    SqlCommand com1 = new SqlCommand(query, con);
    ....
}

```
You're adding the parameters in the loop. If you clear them before adding, this should work.