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

孤者浪人 提交于 2019-11-27 04:01:42

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.

You have to call commit. The using statement will not commit anything for you.

Tommy Hui

I believe that if there's an exception such that Commit() was never called, then the transaction will automatically rollback.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!