Subject Re: [firebird-support] Object in use... wtf???
Author Kjell Rilbe

Den 2013-11-26 10:16 skrev Kjell Rilbe såhär:
 
Den 2013-11-25 23:50 skrev Alan McDonald såhär:
Scenario, in a single connection I do this:

1. Start transaction.
2. Create table.
3. Commit.
4. Start transaction.
5. Insert rows.
6. Select using join with other tables.
7. Commit.
8. Start transaction.
9. Drop table.
 ---> ERROR: Object is in use.

Thank you! Umm... I did find it difficult to determine (docs?) what the various transaction options in the .Net provider really mean for FB, but these are the flags I use for all transactions:

FbTransactionBehavior.ReadCommitted
FbTransactionBehavior.RecVersion
FbTransactionBehavior.Wait

The select is done using this C# construct, which should close and dispose of the query:

using (FbDataReader rd = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow))
{
    rd.Read();
    for (int colnum = 0; colnum < rd.FieldCount; colnum++)
    {
        string colname = rd.GetName(colnum);
        int count = rd.GetInt32(colnum);
        if (count > 0)
            result.Counts[colname] = count;
    }
}

The FbCommand cmd has default settings except this:

cmd.CommandType = System.Data.CommandType.Text;

Anything wrong with these options etc?

Tried to add rd.Close after the for loop, but it didn't help. What did help was to close the connection and reopen it between the select commit and the starting the transaction for the drop.

But why is that necessary?

Regards,
Kjell
-- 
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64