Transaction not rolling back
----------------------------
Key: DNET-540
URL: http://tracker.firebirdsql.org/browse/DNET-540
Project: .NET Data provider
Issue Type: Bug
Components: ADO.NET Provider
Affects Versions: 2.5.2
Environment: Windows 7 and 8
Reporter: pritaeas
Assignee: Jiri Cincura
When I run the below C# code (.NET 3.5 Framework) with
FirebirdSql.Data.FirebirdClient V2.5.1 the TransactionScope works as expected,
not inserting any records at all. If I use the V2.5.2 client then all three
records are inserted into their respective tables. My connection string
contains Enlist = true. I've had identical results using a local and remote
database.
public partial class frmMain : Form
{
private TransactionScopeOption transactionScopeOption;
private TransactionOptions transactionOptions;
public frmMain()
{
InitializeComponent();
transactionScopeOption = TransactionScopeOption.Required;
transactionOptions = new TransactionOptions()
{
IsolationLevel = IsolationLevel.ReadUncommitted,
Timeout = TimeSpan.FromMinutes(2)
};
}
private void btnTestFb_Click(object sender, System.EventArgs e)
{
FbConnection connection = new
FbConnection(ConfigurationManager.ConnectionStrings["ConnectionStringFb"].ConnectionString);
try
{
using (TransactionScope scope = new
TransactionScope(transactionScopeOption, transactionOptions))
{
connection.Open();
NestedInserts(connection);
scope.Complete();
}
connection.Close();
MessageBox.Show("Done.");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void ExecuteNonQuery(FbConnection connection, string
commandText)
{
using (FbCommand command = new FbCommand(commandText, connection))
{
command.ExecuteNonQuery();
}
}
private void NestedInserts(FbConnection connection)
{
using (TransactionScope scope = new
TransactionScope(transactionScopeOption, transactionOptions))
{
InsertA(connection);
scope.Complete();
}
}
private void InsertA(FbConnection connection)
{
using (TransactionScope scope = new
TransactionScope(transactionScopeOption, transactionOptions))
{
ExecuteNonQuery(connection, "INSERT INTO TABLE_A (DESCRIPTION)
VALUES ('A')");
InsertB(connection);
scope.Complete();
}
}
private void InsertB(FbConnection connection)
{
using (TransactionScope scope = new
TransactionScope(transactionScopeOption, transactionOptions))
{
ExecuteNonQuery(connection, "INSERT INTO TABLE_B (DESCRIPTION)
VALUES ('B')");
InsertC(connection);
scope.Complete();
}
}
private void InsertC(FbConnection connection)
{
using (TransactionScope scope = new
TransactionScope(transactionScopeOption, transactionOptions))
{
ExecuteNonQuery(connection, "INSERT INTO TABLE_C (DESCRIPTION)
VALUES ('C')");
InsertD(connection);
scope.Complete();
}
}
private void InsertD(FbConnection connection)
{
using (TransactionScope scope = new TransactionScope())
{
throw new Exception("Fb exception thrown!");
scope.Complete();
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Firebird-net-provider mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider