I am writing a program that uses ADO.NET's SqlCommand to execute a number of user provided batches of T-SQL statements.
My application opens a transaction in which all of the statements are executed to ensure that if there is an error executing any, the whole lot are rolled back.
The problem I have come across is that a badly placed COMMIT (without a matching BEGIN TRAN) in the user provided SQL will commit my all-important transaction and leave me unable to roll back.
Does anybody have any ideas how I can stop the user's SQL from messing with my transaction but still allow them to BEGIN/COMMIT/ROLLBACK their own nested transactions?