<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />

SqlCommand

public sealed class SqlCommand : DbCommand
Represents a Transact-SQL statement or stored procedure to execute against a SQL Server database. This class cannot be inherited.
public SqlConnection Connection { get; set; }

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

Gets the SqlParameterCollection.

public SqlTransaction Transaction { get; set; }

Gets or sets the SqlTransaction within which the SqlCommand executes.

Occurs when the execution of a Transact-SQL statement completes.

public SqlCommand()

Initializes a new instance of the SqlCommand class.

public SqlCommand(string cmdText)

Initializes a new instance of the SqlCommand class with the text of the query.

public SqlCommand(string cmdText, SqlConnection connection)

Initializes a new instance of the SqlCommand class with the text of the query and a SqlConnection.

public SqlCommand(string cmdText, SqlConnection connection, SqlTransaction transaction)

Initializes a new instance of the SqlCommand class with the text of the query, a SqlConnection, and the SqlTransaction.

Creates a new instance of a SqlParameter object.

Sends the CommandText to the Connection and builds a SqlDataReader.

Sends the CommandText to the Connection, and builds a SqlDataReader using one of the CommandBehavior values.

An asynchronous version of ExecuteReader, which sends the CommandText to the Connection and builds a SqlDataReader. Exceptions will be reported via the returned Task object.

An asynchronous version of ExecuteReader, which sends the CommandText to the Connection, and builds a SqlDataReader. Exceptions will be reported via the returned Task object.

An asynchronous version of ExecuteReader, which sends the CommandText to the Connection, and builds a SqlDataReader The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.

An asynchronous version of ExecuteReader, which sends the CommandText to the Connection and builds a SqlDataReader. The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.

Sends the CommandText to the Connection and builds an XmlReader object.

An asynchronous version of ExecuteXmlReader, which sends the CommandText to the Connection and builds an XmlReader object. Exceptions will be reported via the returned Task object.

An asynchronous version of ExecuteXmlReader, which sends the CommandText to the Connection and builds an XmlReader object. The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.