Is there any way to know if a connection is in a transaction?

  • Thread starter Thread starter loquak
  • Start date Start date
L

loquak

Greets.
A very simple question in the topic, probably takes about 10 seconds for an
expert to answer =)
Thanks ..
 
No .... but .. on an open SqlConnection, you can do a CreateCommand and not
enlist that in the transaction .. so in essence a SqlConnection (ADO.NET
object), isn't really on the transaction, but your commands are ... and
those have a transaction property that you can check nulls for.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
No. CreateCommand is the same as "new SqlCommand".
The Transaction property of SqlCommand created by CreateCommand always
returns "null".

Allan
 
Dude - that is exactly what I said ...

"on an open SqlConnection, you can do a CreateCommand and ***NOT*** enlist
that in the transaction"

:-/

Also, CreateCommand is NOT the same as new SqlCommand, it is the same as new
SqlCommand(null,this) // i.e. it sets the connection to itself.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
Back
Top