From: Sam M. <sam...@cl...> - 2004-03-31 14:14:02
|
If you reuse an FbCommand for multiple commands where the first command is not transactioned and the second is then the second will do a commit because the implictTransaction flag is not being reset. e.g. FbCommand Cmd = new FbCommand("SELECT * FROM Table1;", Connection); Cmd.ExecuteNonQuery(); Transaction = Connection.BeginTransaction(); Cmd.Transaction = Transaction; Cmd.CommandText = "INSERT INTO Table1 (Name) VALUES('Fred');"; Cmd.ExecuteNonQuery(); Transaction.Commit; The Commit will fail because the second Execute does a commit. We have fixed this by modifying FbCommand.cs to reset the implicitTransaction flag ... internal void CommitImplicitTransaction() { if (this.implicitTransaction && this.transaction != null) { try { this.transaction.Commit(); } catch (Exception ex) { this.RollbackImplicitTransaction(); throw ex; } finally { this.transaction = null; if (this.statement != null) { this.statement.Transaction = null; } this.implicitTransaction = false; } } } Sam |