1

While SqlTransaction has a Connection property, why does SqlCommand have a constructor with both SqlConnection and SqlTransaction?

Jalil
  • 13
  • 2
  • I presume if you have multiple transactions, you might want to specify which one should be connected to the command. – Stefano d'Antonio Mar 09 '17 at 09:43
  • @Stefanod'Antonio The question is: an `SqlTransaction` already has the `SqlConnection` inside, so why the `SqlCommand` can't have a constructor with only the `SqlTransaction` parameter? – xanatos Mar 09 '17 at 09:44
  • @Jalil I was implying that you might execute a command on a different connection but fail the transaction on another connection if that command fails. But it's just an hypothesis. – Stefano d'Antonio Mar 09 '17 at 09:47
  • Probably wrong by the look of `SqlCommand.ValidateCommand`. But I can't dig further now. – Stefano d'Antonio Mar 09 '17 at 09:49

0 Answers0