M
Mark Hoffman
All,
Is there a way to determine if a connection object is involved in a
transaction? If so, is there a way to get to the transaction object?
Here's what's happening:
I've written a generic database wrapper that lets me easily call SQL
Server, Oracle, Access, etc. In it, I can call a method and pass in an
IDbConnection object, a SQL statement, the command type and
parameters. Everything's been working fine and dandy, but I never
added the ability to handle transactions.
So in the client code, I create a concrete connection object, start a
transaction on that connection object and then toss the connection
object to my generic database layer. Of course, when I attempt to
execute the SQL statement, it now fails because since I've started a
transaction on my connection object, I have to set the Transaction
property on the Command object that is created inside my generic
database layer.
So inside my generic database layer, I have the connection object that
was passed in, I have the command object that the database layer
creates....How do I tell the command object to use the transaction on
the connection object? And of course, only do it if in fact there is a
transaction?
Or am I just screwed?
Is there a way to determine if a connection object is involved in a
transaction? If so, is there a way to get to the transaction object?
Here's what's happening:
I've written a generic database wrapper that lets me easily call SQL
Server, Oracle, Access, etc. In it, I can call a method and pass in an
IDbConnection object, a SQL statement, the command type and
parameters. Everything's been working fine and dandy, but I never
added the ability to handle transactions.
So in the client code, I create a concrete connection object, start a
transaction on that connection object and then toss the connection
object to my generic database layer. Of course, when I attempt to
execute the SQL statement, it now fails because since I've started a
transaction on my connection object, I have to set the Transaction
property on the Command object that is created inside my generic
database layer.
So inside my generic database layer, I have the connection object that
was passed in, I have the command object that the database layer
creates....How do I tell the command object to use the transaction on
the connection object? And of course, only do it if in fact there is a
transaction?
Or am I just screwed?