Question

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();
}
Was it helpful?

Solution

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 );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top