Transactions with untyped dataset

Transactions with untyped dataset

Postby 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?
belidzs
 
Posts: 29
Joined: Wed 30 Sep 2009 12:07

Re: Transactions with untyped dataset

Postby Pinturiccio » Fri 18 May 2012 13:03

Could you please send us a small test project with DDL/DML scripts for reproducing the issue.
Pinturiccio
Devart Team
 
Posts: 2025
Joined: Wed 02 Nov 2011 09:44

Re: Transactions with untyped dataset

Postby belidzs » Sun 20 May 2012 20:54

I've sent the requested files
belidzs
 
Posts: 29
Joined: Wed 30 Sep 2009 12:07

Re: Transactions with untyped dataset

Postby 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.
Pinturiccio
Devart Team
 
Posts: 2025
Joined: Wed 02 Nov 2011 09:44

Re: Transactions with untyped dataset

Postby belidzs » Wed 23 May 2012 08:51

Could you provide an example how to do it?
belidzs
 
Posts: 29
Joined: Wed 30 Sep 2009 12:07

Re: Transactions with untyped dataset

Postby 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
}
Pinturiccio
Devart Team
 
Posts: 2025
Joined: Wed 02 Nov 2011 09:44

Re: Transactions with untyped dataset

Postby belidzs » Wed 23 May 2012 14:34

I was afraid of this. Thank you however!
belidzs
 
Posts: 29
Joined: Wed 30 Sep 2009 12:07


Return to dotConnect for PostgreSQL