แก้ไข

แชร์ผ่าน


SqlDataSourceView.ExecuteUpdate(IDictionary, IDictionary, IDictionary) Method

Definition

Performs an update operation using the UpdateCommand SQL string, any parameters that are in the UpdateParameters collection, and the values that are in the specified keys, values, and oldValues collections.

protected:
 override int ExecuteUpdate(System::Collections::IDictionary ^ keys, System::Collections::IDictionary ^ values, System::Collections::IDictionary ^ oldValues);
protected override int ExecuteUpdate (System.Collections.IDictionary keys, System.Collections.IDictionary values, System.Collections.IDictionary oldValues);
override this.ExecuteUpdate : System.Collections.IDictionary * System.Collections.IDictionary * System.Collections.IDictionary -> int
Protected Overrides Function ExecuteUpdate (keys As IDictionary, values As IDictionary, oldValues As IDictionary) As Integer

Parameters

keys
IDictionary

An IDictionary of primary keys to use with the UpdateCommand property to perform the update database operation. If there are no keys associated with the query or if the UpdateCommand property is not a parameterized SQL query, pass null.

values
IDictionary

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

oldValues
IDictionary

An IDictionary that represents the original values in the database. If there are no parameters associated with the query or if the UpdateCommand property is not a parameterized SQL query, pass null.

Returns

A value that represents the number of rows updated in the underlying database.

Exceptions

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.

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

The CanUpdate property is false.

Remarks

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

The values contained in the keys and values collections are evaluated and merged with any values contained by the UpdateParameters collection. If the ConflictDetection property is set to CompareAllValues, the values contained in the oldValues collection are formatted with the OldValuesParameterFormatString and 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 perform any preprocessing before an update.

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

Applies to

See also