System.Data.SqlClient.SqlCommand.Connection Property

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


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


Documentation for this section has not yet been entered.


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.


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