ObjectDataSourceView.ExecuteUpdate Method

Performs an update operation by calling the method that is identified by the UpdateMethod property and using any parameters that are supplied in the keys, values, or oldValues collections.

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

protected:
virtual int ExecuteUpdate (
	IDictionary^ keys, 
	IDictionary^ values, 
	IDictionary^ oldValues
) override
protected int ExecuteUpdate (
	IDictionary keys, 
	IDictionary values, 
	IDictionary oldValues
)
protected override function ExecuteUpdate (
	keys : IDictionary, 
	values : IDictionary, 
	oldValues : IDictionary
) : int
Not applicable.

Parameters

keys

A IDictionary of primary keys to use with the UpdateMethod property to perform the update database operation. If there are no keys associated with the method, pass a null reference (Nothing in Visual Basic).

values

A IDictionary of values to be used with the UpdateMethod to perform the update database operation. If there are no parameters associated with the method, pass a null reference (Nothing in Visual Basic).

oldValues

A IDictionary that represents the original values in the underlying data store. If there are no parameters associated with the query, pass a null reference (Nothing in Visual Basic).

Return Value

The number of rows updated; or -1, if the number is not known. For more information, see Update.

Exception typeCondition

NotSupportedException

The CanInsert property returns false.

InvalidOperationException

oldValues is a null reference (Nothing in Visual Basic) or empty and ConflictDetection is set to CompareAllValues.

The ObjectDataSourceView class implements the inherited ExecuteUpdate method to update data using a business object. Page developers and data-bound control authors do not call the ExecuteUpdate method directly; instead, use the publicly exposed Update method.

The values that are contained in the keys and values collections are evaluated and merged with any values that are contained by the UpdateParameters 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 update operation is performed, the OnUpdating method is called to raise the Updating event. You can handle this event to examine the values of the parameters and to perform any preprocessing before an update. To perform an update operation, the ObjectDataSourceView uses reflection to call the method that is identified by the UpdateMethod property and any associated parameters in the keys collection, and then executes it. After the operation completes, the OnUpdated method is called to raise the Updated event. You can handle this event to examine any return values, error codes, and perform any post-processing.

For more information on returning the number of rows updated, see Update.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: