Last active
November 22, 2017 09:31
-
-
Save riccardopirani/36bca29a798b19f449838831c2bfd477 to your computer and use it in GitHub Desktop.
SqlException
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String QuerySalvataggioElementi = "Insert into ComponenteOrdine(IdOrdine,CodArt,Descrizione,UM,Quantita) values(@IdOrdine,@CodArt,@Descrizione,@UM,@Quantita)"; | |
cmd = new SqlCommand(QuerySalvataggioElementi, conn); | |
for (int i = 0; i < dataGridViewArticoli.Rows.Count; i++) | |
{ | |
//Controllo se l'articolo è "chekkato prima di aggiungerlo nella tabella temporanea" | |
if (Convert.ToBoolean(dataGridViewArticoli.Rows[i].Cells[6].Value) == true) | |
{ | |
cmd.Parameters.AddWithValue(string.Format("@IdOrdine{0}", i), IdOrdine); | |
cmd.Parameters.AddWithValue(string.Format("@CodArt{0}", i), dataGridViewArticoli.Rows[i].Cells["Codice"].Value.ToString()); | |
cmd.Parameters.AddWithValue(string.Format("@Descrizione{0}", i), dataGridViewArticoli.Rows[i].Cells["Descrizione"].Value.ToString()); | |
cmd.Parameters.AddWithValue(string.Format("@UM{0}", i), dataGridViewArticoli.Rows[i].Cells["UM"].Value.ToString()); | |
cmd.Parameters.AddWithValue(string.Format("@Quantita{0}", i), decimal.Parse(dataGridViewArticoli.Rows[i].Cells["Quantita"].Value.ToString())); | |
cmd.Transaction = transaction; | |
cmd.ExecuteNonQuery(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment