System.Data.SqlClient.SqlCommand.Connection Property

Gets or sets the System.Data.SqlClient.SqlConnection used by this instance of the System.Data.SqlClient.SqlCommand.

Syntax

[System.ComponentModel.Editor("Microsoft.VSDesigner.Data.Design.DbConnectionEditor, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.DefaultValue(null)]
public SqlConnection Connection { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

If the command is enlisted in an existing transaction, and the connection is changed, trying to execute the command will throw an InvalidOperationException.

If the SqlCommand.Transaction property is not null and the transaction has already been committed or rolled back, SqlCommand.Transaction is set to null.

Requirements

Namespace: System.Data.SqlClient
Assembly: System.Data (in System.Data.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0