SqlDataSourceView.ExecuteInsert(IDictionary) 方法

定義

使用 InsertCommand SQL 字串、集合中指定的 InsertParameters 參數及指定 values 集合中的值執行插入操作。

protected:
 override int ExecuteInsert(System::Collections::IDictionary ^ values);
protected override int ExecuteInsert(System.Collections.IDictionary values);
override this.ExecuteInsert : System.Collections.IDictionary -> int
Protected Overrides Function ExecuteInsert (values As IDictionary) As Integer

參數

values
IDictionary

IDictionary一組與屬性一起使用InsertCommand的值,用於執行插入資料庫操作。 如果查詢沒有相關參數,或該 InsertCommand 屬性不是參數化的 SQL 查詢,則傳遞 null

傳回

一個代表插入底層資料庫的列數值。

例外狀況

他們 SqlDataSource 無法與底層資料來源建立連結。

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

IsEditable 屬性為 true。

備註

SqlDataSourceView 類別實作繼承 ExecuteInsert 的方法,將資料插入資料庫。 頁面開發者與資料綁定控制作者不會直接呼叫此 ExecuteInsert 方法;而是使用公開暴露 Insert 的方法。

在執行插入操作前,會呼叫該 OnInserting 方法來啟動 Inserting 事件。 你可以處理此事件來檢查參數值,並在插入前執行任何預處理。

執行插入操作時,物件會SqlDataSourceView利用DbCommand文字及相關InsertCommand屬性建立物件InsertParameters,然後對底層資料庫執行該DbCommand物件。 插入完成後,會呼叫該 OnInserted 方法來啟動事件 Inserted 。 你可以處理此事件來檢查任何回傳值和錯誤代碼,並執行後製處理。

適用於

另請參閱