DbCommand DbCommand DbCommand DbCommand Class

Definition

Represents an SQL statement or stored procedure to execute against a data source. Provides a base class for database-specific classes that represent commands. ExecuteNonQueryAsync

public ref class DbCommand abstract : System::ComponentModel::Component, IDisposable, System::Data::IDbCommand
public abstract class DbCommand : System.ComponentModel.Component, IDisposable, System.Data.IDbCommand
type DbCommand = class
    inherit Component
    interface IDbCommand
    interface IDisposable
Public MustInherit Class DbCommand
Inherits Component
Implements IDbCommand, IDisposable
Inheritance
Derived
Implements

Constructors

DbCommand() DbCommand() DbCommand() DbCommand()

Constructs an instance of the DbCommand object.

Properties

CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

Gets a value indicating whether the component can raise an event.

(Inherited from Component)
CommandText CommandText CommandText CommandText

Gets or sets the text command to run against the data source.

CommandTimeout CommandTimeout CommandTimeout CommandTimeout

Gets or sets the wait time before terminating the attempt to execute a command and generating an error.

CommandType CommandType CommandType CommandType

Indicates or specifies how the CommandText property is interpreted.

Connection Connection Connection Connection

Gets or sets the DbConnection used by this DbCommand.

Container Container Container Container

Gets the IContainer that contains the Component.

(Inherited from Component)
DbConnection DbConnection DbConnection DbConnection

Gets or sets the DbConnection used by this DbCommand.

DbParameterCollection DbParameterCollection DbParameterCollection DbParameterCollection

Gets the collection of DbParameter objects.

DbTransaction DbTransaction DbTransaction DbTransaction

Gets or sets the DbTransaction within which this DbCommand object executes.

DesignMode DesignMode DesignMode DesignMode

Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
DesignTimeVisible DesignTimeVisible DesignTimeVisible DesignTimeVisible

Gets or sets a value indicating whether the command object should be visible in a customized interface control.

Events Events Events Events

Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
Parameters Parameters Parameters Parameters

Gets the collection of DbParameter objects. For more information on parameters, see Configuring Parameters and Parameter Data Types.

Site Site Site Site

Gets or sets the ISite of the Component.

(Inherited from Component)
Transaction Transaction Transaction Transaction

Gets or sets the DbTransaction within which this DbCommand object executes.

UpdatedRowSource UpdatedRowSource UpdatedRowSource UpdatedRowSource

Gets or sets how command results are applied to the DataRow when used by the Update method of a DbDataAdapter.

Methods

Cancel() Cancel() Cancel() Cancel()

Attempts to cancels the execution of a DbCommand.

CreateDbParameter() CreateDbParameter() CreateDbParameter() CreateDbParameter()

Creates a new instance of a DbParameter object.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
CreateParameter() CreateParameter() CreateParameter() CreateParameter()

Creates a new instance of a DbParameter object.

Dispose() Dispose() Dispose() Dispose()
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
ExecuteDbDataReader(CommandBehavior) ExecuteDbDataReader(CommandBehavior) ExecuteDbDataReader(CommandBehavior) ExecuteDbDataReader(CommandBehavior)

Executes the command text against the connection.

ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken) ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken) ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken) ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken)

Providers should implement this method to provide a non-default implementation for ExecuteReader overloads.

The default implementation invokes the synchronous ExecuteReader() method and returns a completed task, blocking the calling thread. The default implementation will return a cancelled task if passed an already cancelled cancellation token. Exceptions thrown by ExecuteReader will be communicated via the returned Task Exception property.

This method accepts a cancellation token that can be used to request the operation to be cancelled early. Implementations may ignore this request.

ExecuteNonQuery() ExecuteNonQuery() ExecuteNonQuery() ExecuteNonQuery()

Executes a SQL statement against a connection object.

ExecuteNonQueryAsync() ExecuteNonQueryAsync() ExecuteNonQueryAsync() ExecuteNonQueryAsync()

An asynchronous version of ExecuteNonQuery(), which executes a SQL statement against a connection object.

Invokes ExecuteNonQueryAsync(CancellationToken) with CancellationToken.None.

ExecuteNonQueryAsync(CancellationToken) ExecuteNonQueryAsync(CancellationToken) ExecuteNonQueryAsync(CancellationToken) ExecuteNonQueryAsync(CancellationToken)

This is the asynchronous version of ExecuteNonQuery(). Providers should override with an appropriate implementation. The cancellation token may optionally be ignored.

The default implementation invokes the synchronous ExecuteNonQuery() method and returns a completed task, blocking the calling thread. The default implementation will return a cancelled task if passed an already cancelled cancellation token. Exceptions thrown by ExecuteNonQuery() will be communicated via the returned Task Exception property.

Do not invoke other methods and properties of the DbCommand object until the returned Task is complete.

ExecuteReader() ExecuteReader() ExecuteReader() ExecuteReader()

Executes the CommandText against the Connection, and returns an DbDataReader.

ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior)

Executes the CommandText against the Connection, and returns an DbDataReader using one of the CommandBehavior values.

ExecuteReaderAsync() ExecuteReaderAsync() ExecuteReaderAsync() ExecuteReaderAsync()

An asynchronous version of ExecuteReader, which executes the CommandText against the Connection and returns a DbDataReader.

Invokes ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken) with CancellationToken.None.

ExecuteReaderAsync(CancellationToken) ExecuteReaderAsync(CancellationToken) ExecuteReaderAsync(CancellationToken) ExecuteReaderAsync(CancellationToken)

An asynchronous version of ExecuteReader, which executes the CommandText against the Connection and returns a DbDataReader. This method propagates a notification that operations should be canceled.

Invokes ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken).

ExecuteReaderAsync(CommandBehavior) ExecuteReaderAsync(CommandBehavior) ExecuteReaderAsync(CommandBehavior) ExecuteReaderAsync(CommandBehavior)

An asynchronous version of ExecuteReader, which executes the CommandText against the Connection and returns a DbDataReader.

Invokes ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken).

ExecuteReaderAsync(CommandBehavior, CancellationToken) ExecuteReaderAsync(CommandBehavior, CancellationToken) ExecuteReaderAsync(CommandBehavior, CancellationToken) ExecuteReaderAsync(CommandBehavior, CancellationToken)

Invokes ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken).

ExecuteScalar() ExecuteScalar() ExecuteScalar() ExecuteScalar()

Executes the query and returns the first column of the first row in the result set returned by the query. All other columns and rows are ignored.

ExecuteScalarAsync() ExecuteScalarAsync() ExecuteScalarAsync() ExecuteScalarAsync()

An asynchronous version of ExecuteScalar(), which executes the query and returns the first column of the first row in the result set returned by the query. All other columns and rows are ignored.

Invokes ExecuteScalarAsync(CancellationToken) with CancellationToken.None.

ExecuteScalarAsync(CancellationToken) ExecuteScalarAsync(CancellationToken) ExecuteScalarAsync(CancellationToken) ExecuteScalarAsync(CancellationToken)

This is the asynchronous version of ExecuteScalar(). Providers should override with an appropriate implementation. The cancellation token may optionally be ignored.

The default implementation invokes the synchronous ExecuteScalar() method and returns a completed task, blocking the calling thread. The default implementation will return a cancelled task if passed an already cancelled cancellation token. Exceptions thrown by ExecuteScalar will be communicated via the returned Task Exception property.

Do not invoke other methods and properties of the DbCommand object until the returned Task is complete.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
Prepare() Prepare() Prepare() Prepare()

Creates a prepared (or compiled) version of the command on the data source.

ToString() ToString() ToString() ToString()

Returns a String containing the name of the Component, if any. This method should not be overridden.

(Inherited from Component)

Explicit Interface Implementations

IDbCommand.Connection IDbCommand.Connection IDbCommand.Connection IDbCommand.Connection

Gets or sets the IDbConnection used by this instance of the IDbCommand.

IDbCommand.CreateParameter() IDbCommand.CreateParameter() IDbCommand.CreateParameter() IDbCommand.CreateParameter()

Creates a new instance of an IDbDataParameter object.

IDbCommand.ExecuteReader() IDbCommand.ExecuteReader() IDbCommand.ExecuteReader() IDbCommand.ExecuteReader()

Executes the CommandText against the Connection and builds an IDataReader.

IDbCommand.ExecuteReader(CommandBehavior) IDbCommand.ExecuteReader(CommandBehavior) IDbCommand.ExecuteReader(CommandBehavior) IDbCommand.ExecuteReader(CommandBehavior)

Executes the CommandText against the Connection, and builds an IDataReader using one of the CommandBehavior values.

IDbCommand.Parameters IDbCommand.Parameters IDbCommand.Parameters IDbCommand.Parameters

Gets the IDataParameterCollection.

IDbCommand.Transaction IDbCommand.Transaction IDbCommand.Transaction IDbCommand.Transaction

Gets or sets the DbTransaction within which this DbCommand object executes.

Events

Disposed Disposed Disposed Disposed

Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)

Applies to