Share via


DataSourceView.ExecuteInsert(IDictionary) 方法

定義

DataSourceView 物件表示的資料清單上,執行插入作業。

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

參數

values
IDictionary

進行插入作業時使用之名稱/值組的 IDictionary

傳回

插入至基礎資料儲存區的項目數目。

例外狀況

範例

下列程式碼範例示範擴充 DataSourceView 類別的類別如何覆寫 CanInsert 屬性和 ExecuteInsert 方法。 此程式碼範例是提供給 類別之較大範例的 DataSourceView 一部分。

// The CsvDataSourceView does not currently
// permit insertion of a new record. You can
// modify or extend this sample to do so.
public override bool CanInsert {
    get {
        return false;
    }
}
protected override int ExecuteInsert(IDictionary values)
{
    throw new NotSupportedException();
}
' The CsvDataSourceView does not currently
' permit insertion of a new record. You can
' modify or extend this sample to do so.
Public Overrides ReadOnly Property CanInsert() As Boolean
   Get
      Return False
   End Get
End Property

Protected Overrides Function ExecuteInsert(values As IDictionary) As Integer
   Throw New NotSupportedException()
End Function 'ExecuteInsert

備註

資料繫結控制項可以使用 方法來擷取 DataSourceView 物件 GetView ,並檢查 CanInsert 屬性,判斷資料來源控制項是否 ExecuteInsert 支援此作業。

參數 values 是一組名稱/值組,代表要插入的資料行或欄位和對應的值。

注意

類別 DataSourceView 的預設實作是擲回例外狀況 NotSupportedException 。 如果您擴充 DataSourceView 類別,如果您的類別支援插入基礎資料儲存體,請覆寫 ExecuteInsert 方法。

適用於

另請參閱