Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Transaction Property

SqlCommand.Transaction Property

Gets or sets the SqlTransaction within which the SqlCommand executes.

[Visual Basic]
Public Property Transaction As SqlTransaction
[C#]
public SqlTransaction Transaction {get; set;}
[C++]
public: __property SqlTransaction* get_Transaction();
public: __property void set_Transaction(SqlTransaction*);
[JScript]
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).

Remarks

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.

Requirements

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

Show:
© 2015 Microsoft