System.InvalidOperationException: 'Transaction has already been rolled back or is not pending'

Code Example - System.InvalidOperationException: 'Transaction has already been rolled back or is not pending'

                
                        // After you commit the transaction, you have to start another one. 
// This means you need to move the BeginTransaction method call into the loop.