views:

21

answers:

0

I wonder, what is the reason to have this SqlCommand constructor overload:

public SqlCommand(
    string cmdText,
    SqlConnection connection,
    SqlTransaction transaction
)

?

When I need to create an internal method that does its bit using a transaction provided as an argument, I always find it sufficient to only pass an SqlTransaction to that method, because, obviously, the connection will be tran.Connection.
Doesn't the same apply to this overload? Would it not be enough to only pass cmdText and transaction?

Is it actually possible to execute an SqlCommand against a connection, providing an SqlTransaction opened against a different SqlConnection? What will this result in?

related questions