2

How I can set this options to FbTransaction

write
nowait
rec_version
read_committed

in my code to execute insert/update sql statements:

FbConnectionStringBuilder fbConnStr = new FbConnectionStringBuilder();

using (FbConnection fbConn = new FbConnection(fbConnStr))
{
   fbConn.Open();
   using (FbTransaction fbTran = fbConn.BeginTransaction())
   {
      using (FbCommand fbCmd = new FbCommand("insert into TEST values (1)", fbConn, fbTran)
      {
         fbCmd.CommandType = CommandType.Text;
         fbCmd.ExecuteNonQuery();
         fbCmd.Transaction.Commit();
      }
   }
   fbConn.Close();
}
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
DaddyRatel
  • 729
  • 3
  • 13
  • 30

1 Answers1

4

You could use FbTransactionOptions:

FbTransaction transaction = Connection.BeginTransaction(
    FbTransactionOptions.ReadCommitted  |
    FbTransactionOptions.Write|
    FbTransactionOptions.RecVersion|
    FbTransactionOptions.NoWait |
    );

Look also at IsolationLevel:

  • IsolationLevel.ReadUncommitted
  • IsolationLevel.ReadCommitted
  • IsolationLevel.RepeatableRead
  • IsolationLevel.Serializable

You could do:

FbTransaction transaction = Connection.BeginTransaction( IsolationLevel.Serializable );
bluish
  • 26,356
  • 27
  • 122
  • 180
danisius
  • 597
  • 1
  • 5
  • 19