Export (0) Print
Expand All

SqlDataSourceView.ExecuteDelete Method

Performs a delete operation using the DeleteCommand SQL string, any parameters that are specified in the DeleteParameters collection, and the values that are in the specified keys and oldValues collections.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

protected override int ExecuteDelete(
	IDictionary keys,
	IDictionary oldValues
)

Parameters

keys
Type: System.Collections.IDictionary

An IDictionary of object or row key values for the ExecuteDelete operation to delete.

oldValues
Type: System.Collections.IDictionary

An IDictionary that contains row values that are evaluated only if the ConflictDetection property is set to the CompareAllValues value.

Return Value

Type: System.Int32
A value that represents the number of rows deleted from the underlying database.

ExceptionCondition
InvalidOperationException

The SqlDataSource cannot establish a connection with the underlying data source.

- or -

The ConflictDetection property is set to the CompareAllValues value and no oldValues parameters are passed.

HttpException

The current user does not have the correct permissions to access to the database.

- or -

The instance of the control is an AccessDataSource control and access is denied to the path specified for the DataFile property.

NotSupportedException

The CanDelete property is false.

- or -

A design-time relative path was not mapped correctly by the designer before using an instance of the AccessDataSource control.

The SqlDataSourceView class implements the inherited ExecuteDelete method to delete data from a database. Page developers and data-bound control authors do not call the ExecuteDelete method directly; instead, use the publicly exposed Delete method.

The values that are contained in the keys collection are evaluated and merged with any values that are contained by the DeleteParameters collection. If the ConflictDetection property is set to the CompareAllValues value, the values that are contained in the oldValues collection are formatted with the OldValuesParameterFormatString property and are also merged.

Before the delete operation is performed, the OnDeleting method is called to raise the Deleting event. You can handle this event to examine the values of the parameters and to perform any preprocessing before a delete.

To perform a delete operation, the SqlDataSourceView object builds a DbCommand object using the DeleteCommand text and any associated DeleteParameters properties, and then executes the DbCommand object against the underlying database. After the delete operation completes, the OnDeleted method is called to raise the Deleted event. You can handle this event to examine any return values and error codes and to perform any post-processing.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft