SqlDataSource.ConflictDetection 属性


获取或设置值,该值指示操作期间基础数据库中的一行数据更改时,SqlDataSource 控件如何执行更新和删除。Gets or sets the value indicating how the SqlDataSource control performs updates and deletes when data in a row in the underlying database changes during the time of the operation.

 property System::Web::UI::ConflictOptions ConflictDetection { System::Web::UI::ConflictOptions get(); void set(System::Web::UI::ConflictOptions value); };
public System.Web.UI.ConflictOptions ConflictDetection { get; set; }
member this.ConflictDetection : System.Web.UI.ConflictOptions with get, set
Public Property ConflictDetection As ConflictOptions


ConflictOptions 值之一。One of the ConflictOptions values. 默认为 OverwriteChanges 值。The default is the OverwriteChanges value.


属性确定是否将旧值和新值的参数应用Update于方法。 ConflictDetectionThe ConflictDetection property determines whether parameters for old and new values are applied to the Update method. 例如, SelectCommand如果属性指定的命令返回一个DataTable具有列OverwriteChanges NameNumberConflictDetection对象, 并且属性设置为值, 则会为Name方法和NumberUpdateFor example, if the command that is specified by the SelectCommand property returns a DataTable object with the columns Name and Number and the ConflictDetection property is set to the OverwriteChanges value, parameters are created for Name and Number for the Update method. CompareAllValues Name Number original_Number如果将original_Name属性设置为值, 则会为、、和创建参数。 ConflictDetectionIf the ConflictDetection property is set to the CompareAllValues value, parameters are created for Name, Number, original_Name, and original_Number. (原始值的参数的准确名称取决于OldValuesParameterFormatString属性。)然后SqlDataSource , 该控件确定UpdateCommand属性Update中指定的方法是否具有匹配的参数。(The exact name of the parameters for the original values depends on the OldValuesParameterFormatString property.) The SqlDataSource control then determines if the Update method that is specified in the UpdateCommand property has parameters that match.

并发控制是一种技术, 当多个客户端访问和操作相同数据时, 数据存储使用该技术来控制如何在存储区中读取和更改数据。Concurrency control is a technique that data stores use to control how data is read and changed in the store when multiple clients are accessing and manipulating the same data. 例如, 一个客户端读取数据并向用户显示数据, 而另一个客户端读取相同的数据, 并将其呈现给其他用户。For example, one client reads data and presents it to a user, while another client reads the same data, and presents it to a different user. 如果这两个用户更新数据并将其提交到数据存储, 则可能会发生一些意外的结果, 因为这两个客户端可能会为同一数据更新不同的值。If both users update the data and submit it to the data storage, some unexpected result might occur, because both clients might update different values for the same data. 这被视为冲突。This is considered a conflict. 通过将ConflictDetection属性设置CompareAllValues为值, 你Update的方法可以将旧值和新值与原始数据源进行比较, 以检测冲突并根据需要处理它们。By setting the ConflictDetection property to the CompareAllValues value, your Update method can then compare the old and new values to the original data source to detect conflicts and handle them, as necessary.

属性委托SqlDataSourceView ConflictDetection给与SqlDataSource控件相关联的对象的属性。 ConflictDetectionThe ConflictDetection property delegates to the ConflictDetection property of the SqlDataSourceView object that is associated with the SqlDataSource control.