System.Web.UI.WebControls.SqlDataSourceView.ExecuteInsert Method

Performs an insert operation using the SqlDataSourceView.InsertCommand SQL string, any parameters that are specified in the SqlDataSourceView.InsertParameters collection, and the values that are in the specified values collection.

Syntax

protected override int ExecuteInsert (IDictionary values)

Parameters

values
An IDictionary of values used with the SqlDataSourceView.InsertCommand property to perform the insert database operation. If there are no parameters associated with the query or if the SqlDataSourceView.InsertCommand property is not a parameterized SQL query, pass null.

Returns

A value that represents the number of rows inserted into the underlying database.

Remarks

The System.Web.UI.WebControls.SqlDataSourceView class implements the inherited System.Web.UI.DataSourceView.ExecuteInsert(IDictionary) method to insert data into a database. Page developers and data-bound control authors do not call the SqlDataSourceView.ExecuteInsert(IDictionary) method directly; instead, use the publicly exposed SqlDataSource.Insert method.

Before the insert operation is performed, the SqlDataSourceView.OnInserting(SqlDataSourceCommandEventArgs) method is called to raise the SqlDataSourceView.Inserting event. You can handle this event to examine the values of the parameters and to perform any preprocessing before an insert.

To perform an insert operation, the System.Web.UI.WebControls.SqlDataSourceView object builds a System.Data.Common.DbCommand object using the SqlDataSourceView.InsertCommand text and any associated SqlDataSourceView.InsertParameters properties, and then executes the System.Data.Common.DbCommand object against the underlying database. After the insert completes, the SqlDataSourceView.OnInserted(SqlDataSourceStatusEventArgs) method is called to raise the SqlDataSourceView.Inserted event. You can handle this event to examine any return values and error codes and to perform any post-processing.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0