I 'stumbled' across some code that gave me a pretty good idea.  Here is what I came up with, is this a good way of doing it?  Also
what would I use for Chaos?  What is a good value for the waittimeout? 

Finally, I need to verify my understanding of the Wait and WaitTimeout.  Wait says if another transaction has the record, wait until either the record is available or until the timeout expires.  If no other transaction has the record, proceed with no waiting.  Is that correct?

here is my sample code.

public enum TransIsoLvl
{
 Chaos
, ReadCommitted
, ReadUnCommitted
, RepeatableRead
, Serializable
, Snapshot
, Unspecified
}

private FbTransactionOptions buildTransOpt(TransIsoLvl isolvl)
{
FbTransactionOptions fbopt = new FbTransactionOptions();
fbopt.TransactionBehavior = FbTransactionBehavior.Wait;
fbopt.WaitTimeout = new TimeSpan(_transtimeout);
switch (isolvl)
{
case TransIsoLvl.ReadCommitted:
fbopt.TransactionBehavior |= FbTransactionBehavior.ReadCommitted;
fbopt.TransactionBehavior |= FbTransactionBehavior.NoRecVersion;
break;
case TransIsoLvl.ReadUnCommitted:
fbopt.TransactionBehavior |= FbTransactionBehavior.ReadCommitted;
fbopt.TransactionBehavior |= FbTransactionBehavior.RecVersion;
break;
case TransIsoLvl.RepeatableRead:
fbopt.TransactionBehavior |= FbTransactionBehavior.Concurrency;
break;
case TransIsoLvl.Serializable:
fbopt.TransactionBehavior |= FbTransactionBehavior.Consistency;
break;
case TransIsoLvl.Snapshot:
fbopt.TransactionBehavior |= FbTransactionBehavior.Concurrency;
break;
}
return fbopt;
}

// then to use, here is an example of use

public void DataAdapterFillDSWTrans(DataSet ds, string sprocname, SProcParam[] parms, TransIsoLvl isolvl = TransIsoLvl.Snapshot)
{
if (ReinitializeConnection())
{
using (FbTransaction trans = conn.BeginTransaction(buildTransOpt(isolvl)))
{

Dixon


On Fri, Mar 21, 2014 at 10:36 AM, E. D. Epperson Jr <dixonepperson@gmail.com> wrote:
Pardon my ignorance but is there any documentation on FbTransaction and FbTransactionOptions?

What I want to do is start a transaction with IsolationLevel of snapshot, and with wait timeout of 1/10 second.

Here is what I've come up with, but not sure I've the correct behavior nor if this is even smart to do this

FbTransactionOptions fbopt = new FbTransactionOptions();
fbopt.WaitTimeout = new TimeSpan(1000000);
fbopt.TransactionBehavior = FbTransactionBehavior.Wait | FbTransactionBehavior.Concurrency;
using(FbTransaction trans = conn.BeginTransaction(fbopt))
{
...
}

Also, since this is a method called by many other methods, I would like to be able to change the IsolationLevel, in code, when needed.  So is this the correct way to do it and is there any documentation what behavior equals what isolation level?

Dixon


On Thu, Mar 20, 2014 at 4:43 PM, Jiri Cincura <diskuze@cincura.net> wrote:
On Thu, Mar 20, 2014 at 3:16 PM, E. D. Epperson Jr
<dixonepperson@gmail.com> wrote:
> recommend something I could try to reduce or eliminate the deadlocks

Without a knowledge of what and why the program is doing this it's
hard to have some advice. Basically you want to eliminate the records
being updated from two transactions at the same time.


--
Jiri {x2} Cincura (x2develop.com founder)
http://blog.cincura.net/ | http://www.ID3renamer.com

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider



--
Dixon Epperson



--
Dixon Epperson