Transactions with untyped dataset

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
belidzs
Posts: 36
Joined: Wed 30 Sep 2009 12:07

Transactions with untyped dataset

Post by belidzs » Thu 17 May 2012 21:50

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?

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Transactions with untyped dataset

Post by Pinturiccio » Fri 18 May 2012 13:03

Could you please send us a small test project with DDL/DML scripts for reproducing the issue.

belidzs
Posts: 36
Joined: Wed 30 Sep 2009 12:07

Re: Transactions with untyped dataset

Post by belidzs » Sun 20 May 2012 20:54

I've sent the requested files

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Transactions with untyped dataset

Post by Pinturiccio » Tue 22 May 2012 10:55

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.

belidzs
Posts: 36
Joined: Wed 30 Sep 2009 12:07

Re: Transactions with untyped dataset

Post by belidzs » Wed 23 May 2012 08:51

Could you provide an example how to do it?

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Transactions with untyped dataset

Post by Pinturiccio » Wed 23 May 2012 13:56

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
}

belidzs
Posts: 36
Joined: Wed 30 Sep 2009 12:07

Re: Transactions with untyped dataset

Post by belidzs » Wed 23 May 2012 14:34

I was afraid of this. Thank you however!

Post Reply