sblandin
sblandin

Reputation: 964

Two consecutive OracleDataAdapter updates inside a TransactionScope

I need to execute some insert instructions from a typed DataSet to a set of tables in my Oracle DB

I do something like:

OracleDataAdapter da1 = new OracleDataAdapter();
da1.InsertCommand = previouslyInitializedCommand;

OracleDataAdapter da2 = new OracleDataAdapter();
da2.InsertCommand = anotherCommand()
...
using (TransactionScope ts = new TransactionScope())
using (OracleConnecction conn = new OracleConnection(connString))
{
    da1.InsertCommand.Connection = conn;
    da2.InsertCommand.Connection = conn;

    da1.Update(dataset.Table1);
    da2.Update(dataset.Table2);

    ts.Complete();
}

The second Update never happens because the first one change the row status of Table2 to "Unmodified". Anyone knows why this happens?

Upvotes: 1

Views: 113

Answers (1)

sblandin
sblandin

Reputation: 964

Now it works...

I have done two things:

  1. Changed from the dataset designer the accept/reject rule of the relation that links Table1 to Table2 from Cascade to None.

  2. I have set the UpdatedRowSource to Both.

Upvotes: 1

Related Questions