The way I solve it in my code is to create a class that manages
database connection,transactions and commands: eg. DatabaseContext
pseudo code:
context.begin_transaction() // opens connection, starts transaction
context.runsql(sql)  // creates command using current connection and transaction
context.commit_transaction() // commits transaction, closes connection

You then pass around the database context class instead of the
database connection.
In Firebird everything has a transaction even if it's created by the
.net driver transparently in background, so it's better to always have
an explicit transaction in your code, makes for fewer surprises.

~Gerdus

On Wed, Apr 11, 2012 at 9:59 AM, Russell Rose <russ...@passfield.co.uk> wrote:
> I was wondering if there was any way to determine if there is a pending
> transaction outstanding.  I have a single connection to a database and have
> something like the following code:
>
>
>
> FbConnection conn;
>
> FBCommand cmd = conn.CreateCommand();;
>
> cmd.Transaction = conn.BeginTransaction();
>
>
>
> I then call another generic routine which starts up a new command:
>
> Cmd2 = conn.CreateCommand();
>
>
>
> I get the following error:
>
> Execute requires the Command object to have a Transaction object when the
> Connection object assigned to the command is in a pending local transaction.
> The Transaction property of the Command has not been initialized.
>
>
>
> The 2nd routine is sometimes called when there is a pending transaction and
> sometimes not.
>
>
>
>
> ------------------------------------------------------------------------------
> Better than sec? Nothing is better than sec when it comes to
> monitoring Big Data applications. Try Boundary one-second
> resolution app monitoring today. Free.
> http://p.sf.net/sfu/Boundary-dev2dev
> _______________________________________________
> Firebird-net-provider mailing list
> Firebird-net-provider@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
>

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to