The code is as follows, I'm doing an insert from the values of a data grid view
foreach (DataGridViewRow row in dgvCON.Rows)
{
MySqlCommand cmd = new MySqlCommand();
cmd = conectabanco.CreateCommand();
if (row.IsNewRow) continue;
cmd.Parameters.AddWithValue("@IdProd", row.Cells["Id"].Value);
cmd.Parameters.AddWithValue("@QtdProd", row.Cells["Quantidade"].Value);
cmd.Parameters.AddWithValue("@NomeProd", row.Cells["Nome"].Value);
cmd.Parameters.AddWithValue("@PrecoUnitProd", row.Cells["R$ Unidade"].Value);
cmd.Parameters.AddWithValue("@TotalListaConsu", row.Cells["Total"].Value);
cmd.CommandText = "INSERT INTO listaconsumo(IdCon, IdProd, QtdProd, PrecoUnitProd, " +
"totalListaConsu)VALUES("+idconsumo+", @IdProd, @QtdProd, @NomeProd, @PrecoUnitProd, @totalListaConsu)";
cmd.ExecuteNonQuery();
}
The problem is that when executing Sql, it sends pro insert the value "@IDProd" itself, rather than being replaced by the value of the datagridview