SqlDataSourceView.ExecuteDelete(IDictionary, IDictionary) 方法

定義

使用 DeleteCommand SQL 字串、DeleteParameters 集合中指定的任何參數,以及 keysoldValues 集合中指定的值,執行刪除作業。

protected:
 override int ExecuteDelete(System::Collections::IDictionary ^ keys, System::Collections::IDictionary ^ oldValues);
protected override int ExecuteDelete (System.Collections.IDictionary keys, System.Collections.IDictionary oldValues);
override this.ExecuteDelete : System.Collections.IDictionary * System.Collections.IDictionary -> int
Protected Overrides Function ExecuteDelete (keys As IDictionary, oldValues As IDictionary) As Integer

參數

keys
IDictionary

要刪除的 IDictionary 作業之物件的 ExecuteDelete(IDictionary, IDictionary) 或資料列索引鍵值。

oldValues
IDictionary

IDictionary,包含的資料列值只有在 ConflictDetection 屬性設為 CompareAllValues 值時才會評估。

傳回

表示從基礎資料庫刪除之資料列數的值。

例外狀況

SqlDataSource 不能以基礎資料來源建立連接。

-或-

ConflictDetection 屬性設為 CompareAllValues 值,且不傳遞任何 oldValues 參數。

目前的使用者沒有存取資料庫的正確使用權限。

-或-

控制項的執行個體為 AccessDataSource 控制項,且拒絕存取指定給 DataFile 屬性的路徑。

CanDelete 屬性為 false

-或-

在使用 AccessDataSource 控制項的執行個體之前,設計工具未正確對應設計階段相對路徑。

備註

類別 SqlDataSourceView 會實作繼承 ExecuteDelete 的方法,以從資料庫刪除資料。 頁面開發人員和資料系結控制項作者不會直接呼叫 ExecuteDelete 方法;而是使用公開的方法 Delete

包含在集合中的 keys 值會評估併合並至集合所包含的 DeleteParameters 任何值。 ConflictDetection如果屬性設定為 CompareAllValues 值,則集合中包含的 oldValues 值會以 OldValuesParameterFormatString 屬性格式化,也會合並。

在執行刪除作業之前,會 OnDeleting 呼叫 方法來引發 Deleting 事件。 您可以處理此事件來檢查參數的值,並在刪除之前執行任何前置處理。

若要執行刪除作業, SqlDataSourceView 物件會使用 DeleteCommand 文字和任何相關聯的 DeleteParameters 屬性來建置 DbCommand 物件,然後針對基礎資料庫執行 DbCommand 物件。 刪除作業完成之後, OnDeleted 會呼叫 方法來引發 Deleted 事件。 您可以處理此事件來檢查任何傳回值和錯誤碼,以及執行任何後續處理。

適用於

另請參閱