for (int i = 0; i < dataGridView1.Rows.Count - 1; i++) {
// try
// {
SqlConnection sqlConn = new SqlConnection(connect);
sqlConn.Open();
SqlCommand command = new SqlCommand("insert into Orders (Id, InvoiceId, ProductId, Price, Quantity) values (@i, @in, @p, @pr, @q)", sqlConn);
command.Parameters.AddWithValue("@i", dataGridView1.Rows.Cells["Id"].Value);
command.Parameters.AddWithValue("@in", dataGridView1.Rows.Cells["InvoiceId"].Value);
command.Parameters.AddWithValue("@p", dataGridView1.Rows.Cells["ProductId"].Value);
command.Parameters.AddWithValue("@pr", dataGridView1.Rows.Cells["Price"].Value);
command.Parameters.AddWithValue("@q", dataGridView1.Rows.Cells["Quantity"].Value);
command.ExecuteNonQuery();
sqlConn.Close();
// }
// catch (Exception ex)
// {
// MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
// }
//}
MessageBox.Show("Insert OK");
}