SqlDataSourceView.ExecuteUpdate(IDictionary, IDictionary, IDictionary) 方法

定義

使用 UpdateCommand SQL 字串、UpdateParameters 集合中指定的任何參數,以及 keysvaluesoldValues 集合中指定的值,執行更新作業。

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

參數

keys
IDictionary

主索引鍵的 IDictionary,與 UpdateCommand 屬性搭配使用,以執行更新資料庫作業。 如果沒有任何索引鍵與查詢關聯,或 UpdateCommand 屬性不是參數型的 SQL 查詢,則會傳遞 null

values
IDictionary

值的 IDictionary,與 UpdateCommand 屬性搭配使用,以執行更新資料庫作業。 如果沒有任何參數與查詢有關聯,或是 UpdateCommand 不是參數型的 SQL 查詢,則會傳遞 null

oldValues
IDictionary

IDictionary,表示資料庫中的原始值。 如果沒有任何參數與查詢關聯,或 UpdateCommand 屬性不是參數型的 SQL 查詢,則會傳遞 null

傳回

表示基礎資料庫中更新之資料列數的值。

例外狀況

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

-或-

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

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

CanUpdate 屬性為 false

備註

類別 SqlDataSourceView 會實作繼承 ExecuteUpdate 的方法,以更新資料庫中的資料。 頁面開發人員和資料繫結控制項作者不會直接呼叫 ExecuteUpdate 方法;請改用公開的方法 Update

values 集合中包含的 keys 值會進行評估,並與集合所包含的 UpdateParameters 任何值合併。 ConflictDetection如果 屬性設定為 CompareAllValues ,則集合中包含的 oldValues 值會格式化為 , OldValuesParameterFormatString 而且也會合並。

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

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

適用於

另請參閱