Export (0) Print
Expand All

SqlCommand.Transaction Property

Gets or sets the SqlTransaction within which the SqlCommand executes.

[Visual Basic]
Public Property Transaction As SqlTransaction
public SqlTransaction Transaction {get; set;}
public: __property SqlTransaction* get_Transaction();
public: __property void set_Transaction(SqlTransaction*);
public function get Transaction() : SqlTransaction;
public function set Transaction(SqlTransaction);

Property Value

The SqlTransaction. The default value is a null reference (Nothing in Visual Basic).


You cannot set the Transaction property if it is already set to a specific value, and the command is in the process of executing. If you set the transaction property to a SqlTransaction object that is not connected to the same SqlConnection as the SqlCommand object, an exception will be thrown the next time you attempt to execute a statement.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

SqlCommand Class | SqlCommand Members | System.Data.SqlClient Namespace

© 2014 Microsoft