Page 1 of 1

Transactions with untyped dataset

Posted: Thu 17 May 2012 21:50
by belidzs
I'm trying to post changes using an untyped dataset and a stored procedure in the same transaction using dotConnect Professional. The problem is that if posting dataset succeeds, but the stored procedure afterwards doesn't, rolling back the transaction doesn't roll back the dataset to its original state, the dataset looks like it has been successfully commited. Is there any solution to avoid this problem?

Re: Transactions with untyped dataset

Posted: Fri 18 May 2012 13:03
by Pinturiccio
Could you please send us a small test project with DDL/DML scripts for reproducing the issue.

Re: Transactions with untyped dataset

Posted: Sun 20 May 2012 20:54
by belidzs
I've sent the requested files

Re: Transactions with untyped dataset

Posted: Tue 22 May 2012 10:55
by Pinturiccio
When you execute the Rollback method, you do not make changes to the database. At the same time, by calling the Update method for your table, you changed the state of the added row from RowState.Added to RowState.Unchanged.
The Commit and Rollback functions influence only the changes made to the database. After calling the Rollback function, the situation can occur, when data on the server and on the client in the dataset will desynchronize, in this case you will have to synchronize the row statuses yourself.

Re: Transactions with untyped dataset

Posted: Wed 23 May 2012 08:51
by belidzs
Could you provide an example how to do it?

Re: Transactions with untyped dataset

Posted: Wed 23 May 2012 13:56
by Pinturiccio
In your test project you add one dr row to PgSqlDataTable. I'm posting here an example for this row. However you have to track all rows being added or changed in your table yourself in your code.

For the dr row you have to add the following code in the catch block.

Code: Select all

catch (PgSqlException) 
{
            //rolling back
            pgSqlConnection1.Rollback();
            dr.SetAdded(); // table1Table.Update() will return 1
}

Re: Transactions with untyped dataset

Posted: Wed 23 May 2012 14:34
by belidzs
I was afraid of this. Thank you however!