DbCommand 類別

定義

表示要對資料來源執行的 SQL 陳述式或預存程序。 提供代表命令之資料庫特有類別的基底類別。 ExecuteNonQueryAsync.

public ref class DbCommand abstract : IDisposable
public ref class DbCommand abstract : System::ComponentModel::Component, IAsyncDisposable, IDisposable, System::Data::IDbCommand
public ref class DbCommand abstract : IDisposable, System::Data::IDbCommand
public ref class DbCommand abstract : System::ComponentModel::Component, IDisposable, System::Data::IDbCommand
public ref class DbCommand abstract : System::ComponentModel::Component, System::Data::IDbCommand
public ref class DbCommand abstract : System::ComponentModel::Component, IAsyncDisposable, System::Data::IDbCommand
public abstract class DbCommand : IDisposable
public abstract class DbCommand : System.ComponentModel.Component, IAsyncDisposable, IDisposable, System.Data.IDbCommand
public abstract class DbCommand : IDisposable, System.Data.IDbCommand
public abstract class DbCommand : System.ComponentModel.Component, IDisposable, System.Data.IDbCommand
public abstract class DbCommand : System.ComponentModel.Component, System.Data.IDbCommand
public abstract class DbCommand : System.ComponentModel.Component, IAsyncDisposable, System.Data.IDbCommand
type DbCommand = class
    interface IDisposable
type DbCommand = class
    inherit Component
    interface IDbCommand
    interface IDisposable
    interface IAsyncDisposable
type DbCommand = class
    interface IDbCommand
    interface IDisposable
type DbCommand = class
    inherit Component
    interface IDbCommand
    interface IDisposable
Public MustInherit Class DbCommand
Implements IDisposable
Public MustInherit Class DbCommand
Inherits Component
Implements IAsyncDisposable, IDbCommand, IDisposable
Public MustInherit Class DbCommand
Implements IDbCommand, IDisposable
Public MustInherit Class DbCommand
Inherits Component
Implements IDbCommand, IDisposable
Public MustInherit Class DbCommand
Inherits Component
Implements IDbCommand
Public MustInherit Class DbCommand
Inherits Component
Implements IAsyncDisposable, IDbCommand
繼承
DbCommand
繼承
衍生
實作

建構函式

DbCommand()

建構 DbCommand 物件的執行個體。

屬性

CanRaiseEvents

取得值,指出元件是否能引發事件。

(繼承來源 Component)
CommandText

取得或設定要對資料來源執行的文字命令。

CommandTimeout

取得或設定在終止執行命令併產生錯誤之前,) 以秒為單位 (等候時間。

CommandType

取得或設定如何 CommandText 解譯屬性。

Connection

取得或設定這個 DbConnection 所使用的 DbCommand

Container

取得包含 IContainerComponent

(繼承來源 Component)
DbConnection

取得或設定這個 DbConnection 所使用的 DbCommand

DbParameterCollection

取得 DbParameter 物件的集合。

DbTransaction

取得或設定 DbTransaction,此 DbCommand 物件會在其中執行。

DesignMode

取得值,指出 Component 目前是否處於設計模式。

(繼承來源 Component)
DesignTimeVisible

取得或設定值,指出命令物件是否應該在自訂介面控制項中顯示。

Events

取得附加在這個 Component 上的事件處理常式清單。

(繼承來源 Component)
Parameters

取得 DbParameter 物件的集合。 如需參數的詳細資訊,請參閱設定參數和參數資料類型

Site

取得或設定 ComponentISite

(繼承來源 Component)
Transaction

取得或設定 DbTransaction,此 DbCommand 物件會在其中執行。

UpdatedRowSource

取得或設定當由 DataRow 的 Update 方法使用命令結果時,如何套用至 DbDataAdapter

方法

Cancel()

嘗試取消的執行 DbCommand

CreateDbParameter()

建立 DbParameter 物件的新執行個體。

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。

(繼承來源 MarshalByRefObject)
CreateParameter()

建立 DbParameter 物件的新執行個體。

Dispose()

執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。

Dispose()

釋放 Component 所使用的所有資源。

(繼承來源 Component)
Dispose(Boolean)

釋放 DbCommand 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

Dispose(Boolean)

釋放 Component 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 Component)
DisposeAsync()

非同步地處置命令物件。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
ExecuteDbDataReader(CommandBehavior)

針對其連線執行命令,傳 DbDataReader 回可用來存取結果的 。

ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken)

提供者應該實作這個方法,以提供 ExecuteReader 多載的非預設實作。

預設實作會叫用同步ExecuteReader()方法,並傳回完成的工作,封鎖呼叫的執行緒。 如果傳遞一個已經被取消的取消語彙基元,預設實作會傳回已取消的工作。 ExecuteReader 擲回的例外狀況會透過傳回的 Task Exception 屬性來傳送。

這個方法會接受可以用來要求提早取消作業的取消語彙基元。 實作可以忽略這項要求。

ExecuteNonQuery()

針對其連接物件執行命令,傳回受影響的數據列數目。

ExecuteNonQueryAsync()

異步 ExecuteNonQuery()版本的 ,它會對其連接物件執行命令,並傳回受影響的數據列數目。

以 CancellationToken.None 叫用 ExecuteNonQueryAsync(CancellationToken)

ExecuteNonQueryAsync(CancellationToken)

這是 ExecuteNonQuery() 的非同步版本。 提供者應該覆寫為適當的實作。 可以選擇性地接受忽略語彙基元。

預設實作會叫用同步ExecuteNonQuery()方法,並傳回完成的工作,封鎖呼叫的執行緒。 如果傳遞一個已經被取消的取消語彙基元,預設實作會傳回已取消的工作。 ExecuteNonQuery() 擲回的例外狀況會透過傳回的工作例外狀況屬性來傳送。

在傳回的工作完成之前,不叫用 DbCommand 物件的其他方法及屬性。

ExecuteReader()

針對其連線執行命令,傳 DbDataReader 回可用來存取結果的 。

ExecuteReader(CommandBehavior)

針對其連線執行命令,傳 DbDataReader 回可用來存取結果的 。

ExecuteReaderAsync()

異步 ExecuteReader版本的 ,它會對其連線執行命令,並 DbDataReader 傳回可用來存取結果的 。

以 CancellationToken.None 叫用 ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken)

ExecuteReaderAsync(CancellationToken)

異步 ExecuteReader版本的 ,它會對其連線執行命令,並 DbDataReader 傳回可用來存取結果的 。

叫用 ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken)

ExecuteReaderAsync(CommandBehavior)

異步 ExecuteReader版本的 ,它會對其連線執行命令,並 DbDataReader 傳回可用來存取結果的 。

叫用 ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken)

ExecuteReaderAsync(CommandBehavior, CancellationToken)

叫用 ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken)

ExecuteScalar()

執行 命令,並傳回第一個傳回結果集中第一個數據列的第一個數據行。 所有其他數據行、數據列和結果集都會被忽略。

ExecuteScalarAsync()

ExecuteScalar()異步版本,它會執行 命令,並傳回第一個傳回結果集中第一個數據列的第一個數據行。 所有其他數據行、數據列和結果集都會被忽略。

以 CancellationToken.None 叫用 ExecuteScalarAsync(CancellationToken)

ExecuteScalarAsync(CancellationToken)

這是 ExecuteScalar() 的非同步版本。 提供者應該覆寫為適當的實作。 可以選擇性地接受忽略語彙基元。

預設實作會叫用同步ExecuteScalar()方法,並傳回完成的工作,封鎖呼叫的執行緒。 如果傳遞一個已經被取消的取消語彙基元,預設實作會傳回已取消的工作。 ExecuteScalar 擲回的例外狀況會透過傳回的工作例外狀況屬性來傳送。

在傳回的工作完成之前,不叫用 DbCommand 物件的其他方法及屬性。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLifetimeService()
已淘汰.

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。

(繼承來源 MarshalByRefObject)
GetService(Type)

傳回表示 Component 或其 Container 所提供之服務的物件。

(繼承來源 Component)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
InitializeLifetimeService()
已淘汰.

取得存留期服務物件,以控制這個執行個體的存留期原則。

(繼承來源 MarshalByRefObject)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。

(繼承來源 MarshalByRefObject)
Prepare()

在資料來源上建立命令已備妥 (或已編譯) 的版本。

PrepareAsync(CancellationToken)

在資料來源上非同步地建立預先準備 (或預先編譯) 版本的命令。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
ToString()

傳回任何包含 Component 名稱的 String。 不應覆寫此方法。

(繼承來源 Component)

事件

Disposed

Dispose() 方法的呼叫處置元件時,就會發生。

(繼承來源 Component)

明確介面實作

IDbCommand.Connection

取得或設定 IDbCommand 的這個執行個體所使用的 IDbConnection

IDbCommand.CreateParameter()

建立 IDbDataParameter 物件的新執行個體。

IDbCommand.ExecuteReader()

針對 Connection 執行 CommandText,並建置 IDataReader

IDbCommand.ExecuteReader(CommandBehavior)

針對 Connection 執行 CommandText,並使用其中一個 CommandBehavior 值來建置 IDataReader

IDbCommand.Parameters

取得 IDataParameterCollection

IDbCommand.Transaction

取得或設定 DbTransaction,此 DbCommand 物件會在其中執行。

擴充方法

ConfigureAwait(IAsyncDisposable, Boolean)

設定如何執行從非同步可處置項目傳回的工作 await。

適用於

另請參閱