foreach (DataGridViewRow dgvr in ordenesDataGridView.Rows)
{
SqlCommand command = ordenesTableAdapter.Connection.CreateCommand();
SqlTransaction transaction;
ordenesTableAdapter.Connection.Open();
transaction = ordenesTableAdapter.Connection.BeginTransaction();
command.Connection = ordenesTableAdapter.Connection;
command.Transaction = transaction;
try
{
this.ordenesTableAdapter.Insert(1, "Calibrar");
transaction.Commit();
MessageBox.Show("Insert OK");
}
catch (Exception ex)
{
MessageBox.Show("Fallo en la transacción.");
try
{
transaction.Rollback();
}
catch (Exception ex2)
{
MessageBox.Show("Fallo en rollback");
}
}
ordenesTableAdapter.Connection.Close();
}