Read the error:
Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements
Now look at your SQL code, and manually match up the start and end statements.
We can;t do that for you: we don't have any access to your code...