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

SqlCommand

public sealed class SqlCommand : DbCommand, ICloneable
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.

public SqlNotificationRequest Notification { get; set; }

Gets or sets a value that specifies the SqlNotificationRequest object bound to this command.

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.

Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this SqlCommand.

public IAsyncResult BeginExecuteNonQuery(AsyncCallback callback, object stateObject)

Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this SqlCommand, given a callback procedure and state information.

Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this SqlCommand, and retrieves one or more result sets from the server.

public IAsyncResult BeginExecuteReader(AsyncCallback callback, object stateObject)

Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this SqlCommand and retrieves one or more result sets from the server, given a callback procedure and state information.

public IAsyncResult BeginExecuteReader(AsyncCallback callback, object stateObject, CommandBehavior behavior)

Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this SqlCommand, using one of the CommandBehavior values, and retrieving one or more result sets from the server, given a callback procedure and state information.

Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this SqlCommand using one of the CommandBehavior values.

Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this SqlCommand and returns results as an XmlReader object.

public IAsyncResult BeginExecuteXmlReader(AsyncCallback callback, object stateObject)

Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this SqlCommand and returns results as an XmlReader object, using a callback procedure.

public SqlCommand Clone()

Creates a new SqlCommand object that is a copy of the current instance.

Creates a new instance of a SqlParameter object.

public int EndExecuteNonQuery(IAsyncResult asyncResult)

Finishes asynchronous execution of a Transact-SQL statement.

Finishes asynchronous execution of a Transact-SQL statement, returning the requested SqlDataReader.

Finishes asynchronous execution of a Transact-SQL statement, returning the requested data as XML.

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.

public void ResetCommandTimeout()

Resets the CommandTimeout property to its default value.