Will a using statement rollback a database transaction if an error occurs?

Dispose method for transaction class performs a rollback while Oracle’s class doesn’t. So from transaction’s perspective it’s implementation dependent.

The using statement for the connection object on the other hand would either close the connection to the database or return the connection to the pool after resetting it. In either case, the outstanding transactions should be rolled back. That’s why an exception never leaves an active transaction lying around.

Also, yes, you should call Commit() explicitly.

Leave a Comment