Hi, We are currently using the .NET OleDB Provider to connect to a SQL Anywhere 11.0.1 database and everything is working fine. We were looking into moving to the SQL Anywhere .NET provider for performance reasons, but we have not been able to get transactions to work like they are for us currently. In the code below we create an SATransaction from the connection and then execute an insert on that transaction. We then call the transaction's Rollback, but the row that we just added is not rolled back. Is there something that we are missing or doing incorrectly?
This test fails on the last assert, because there are two rows in the table. Thanks, asked 16 Apr '14, 13:21 dmurty |
OK, so I think I figured it out. I created a C# test just to make sure that that was not the issue and it too failed. I then suspecting the database. In looking at some of the options I noticed that the option chained was turned off. Once I turned that on the tests pass! For some reason the OLEDB provider worked with the Chained option off. answered 17 Apr '14, 14:26 dmurty 1
Ah, that's why Breck always recommends to set CHAINED "on" to prevent the obstacles of server-side autocommit mode - glad you got it working:) FWIW: If you feel you have solved the case, I'd suggest that you turn your own comment into an answer and accept it.
(17 Apr '14, 14:46)
Volker Barth
1
When you enter into transaction mode, the .NET provider sets the isolation level but does nothing about ensuring that chained is "on". The OLE DB provider goes to great lengths to control autocommit behaviour.
(17 Apr '14, 15:09)
JBSchueler
|
Why do you call ExecuteReader() for an INSERT?
Was trying different things. If we call executeNonQuery it gives the same results
Your code seems correct, you can check if the Rollback is really the problem if you check the database table by yourself after the call to Rollback. I guess it might be more a problem with the ExecuteScalar not really revisiting the table data... By the way which exact Version of 11.0.1 are your using?
I tried the equivalent C# test wtih a .NET 2.0 provider version 11.0.1.30692. It works for me. I populated a table with 3 rows. The counts went from 3 to 4 and back to 3.
What version of iAnywhere.Data.SQLAnywhere are you using?
Running SQL Anywhere Network Server Version 11.0.1.3069 OEM Authenticated Edition
Referencing iAnywhere.Data.SQLAnywhere.v4.0 version 11.0.1.30694