Oracle Transaction Management: Ensuring Data Consistency with Commit and Rollback

Feedback


Solution 1:

Most likely you need to add:

cmd.Transaction = tran;

after calling

BeginTransaction

.

If

cmd

is not specified as part of the transaction, then the runtime will not recognize its inclusion, as stated in

tran

.

For details see the documentation.


Solution 2:


In my comment, I suggest looking into the Autocommit property of the connection.

As Oracle’s documentation states

The current transaction’s Commit call after executing each SQL statement is determined by this property. If not, it defaults to false, while the default value is true.

So at least try

conn.Autocommit=false;

Frequently Asked Questions

Posted in Uncategorized