語言

OleDbCommand.CommandType 屬性

定義

取得或設定一個值,指示屬性的 CommandText 解讀方式。

public:
 virtual property System::Data::CommandType CommandType { System::Data::CommandType get(); void set(System::Data::CommandType value); };
public:
 property System::Data::CommandType CommandType { System::Data::CommandType get(); void set(System::Data::CommandType value); };
public override System.Data.CommandType CommandType { get; set; }
[System.Data.DataSysDescription("DbCommand_CommandType")]
public System.Data.CommandType CommandType { get; set; }
member this.CommandType : System.Data.CommandType with get, set
[<System.Data.DataSysDescription("DbCommand_CommandType")>]
member this.CommandType : System.Data.CommandType with get, set
Public Overrides Property CommandType As CommandType
Public Property CommandType As CommandType

屬性值

這是其中一項 CommandType 價值。 預設為 Text。

實作

屬性

例外狀況

該值並非有效 CommandType。

備註

當你將屬性設 CommandType 為 StoredProcedure時,應該將該屬性設 CommandText 為儲存程序的名稱。 當你呼叫其中一個 Execute 方法時,指令會執行這個儲存程序。

Connection若目前連線正在執行執行或擷取操作,則無法設定 , CommandType 和 CommandText 屬性。

OLE DB .NET 提供者不支援將參數傳給 SQL 陳述式或由 當 置為 Text 時呼叫OleDbCommandCommandType的儲存程序的命名參數。 此時必須使用問號(?)佔位符。 例如:

SELECT * FROM Customers WHERE CustomerID = ?

因此,物件加入的OleDbParameter順序OleDbParameterCollection必須直接對應該參數的問號佔位符的位置。 欲了解更多資訊,請參閱 「參數與參數資料型態的配置」。

適用於

另請參閱