Open concurrency, Data Binding Control and Data Source Control (sqldatasource) Returned Database copy dataview (Dataset)

Source: Internet
Author: User

After the data source control (sqldatasource) extracts data from the database according to the SELECT command, a dataview (Dataset) is generated to a data binding control (tabular data binding control, hierarchical Data Binding control ). The data binding control maintains the dataview (Dataset).When the data is bound to the control, the data is displayed from the dataview (Dataset) maintained by the data itself. During each update, the data in the WHERE clause in the delete operation is maintained by the user.Obtained from dataview (Dataset) If the data binding control explicitly uses the databind () method (the data binding control does not have a select event), it explicitly requires the data source control (sqldatasource) to return a new dataview (Dataset) give it to him. When the data binding control executes update and delete specifies the WHERE clause, the original value of each column in the entire row is used as the judgment condition, making update and deletion safer, because dataview (Dataset) maintained by the data binding control is a database cache, we cannot know whether the data in the database has changed at this time, in the WHERE clause, the original value of each column in the entire row is used as the judgment condition (each row of dataset passes through system. data . Datarowversion maintains four statuses. This prevents the sqldatasource control from returning the updated data in the database or the sqldatasource control after dataview (Dataset) is updated to the data binding control) return the data deleted from the database after dataview (Dataset) is bound to the Data Control.

For example

Database Table (assume there is only one row)
A B C
1 2 2
The data source control (sqldatasource) returns a copy of the database table dataview (Dataset) to the data binding control)
A B C
1 2 2
The database's chlorophyll table has been modified.
A B C
1 23
The data binding control also needs to modify this data. If there is no open concurrency, this SQL statement may write update chlorophyll set C = 3 where a = 1, and the database table is modified again.
However, if open concurrency is used, this QL statement may write the following statement: Update chlorophyll set C = 3 where a = 1, B = 2, C = 2 (note that the three values after where are the original values of this row, that is, datarow. ["",Datarowversion.Original],Datarow. ["B ",Datarowversion.Original],Datarow. ["C ",Datarowversion.Value obtained by original. In this way, the data source control is used(Sqldatasource) execute this update. This row cannot be found in the database, because it is modified after dataview (Dataset) is returned for the data binding control.

Data protection can be improved through open concurrency and concurrent concurrency (locking rows during update and delete operations ).

in a multi-user environment, there are two models used to update data in the database: open concurrency and parallel concurrency. Dataset objects are designed to facilitate the use of open concurrency for long-running activities, for example, when you remotely process data and interact with the data.

concurrent locking involves locking rows in the data source to prevent users from affecting other users due to data modification. When a user executes an operation that will apply the lock, other users cannot perform any operation that may conflict with the lock until the lock owner releases the lock. This model is mainly used in the following environments: there is fierce competition for data; the cost of using locks to protect data is less than the cost of rolling back transactions in the case of concurrent conflicts.

therefore, in a parallel concurrency model, if a user has the intention to change a row while reading the data, the user establishes a lock. No other user can change the lock row before the user completes the update and releases the lock. Because of this, if the lock time will be relatively short (for example, when processing records programmatically), it is best to implement parallel concurrency. When a user interacts with the data, concurrent concurrency is not a scalable option, which will lock the record for a relatively long time.

In contrast, users using open concurrency do not lock the row when reading data. When you want to update a row, the Program must be applied to determine whether other users have changed the row since the row was read. open concurrency is usually used in environments with less contention for data. Because you do not need to lock any record, it will improve performance, because the lock record requires additional server resources. In addition, to maintain the record lock, you must maintain a persistent connection with the database server. Because this is not the case in the open concurrency model, connections to the server can provide services for a large number of clients in a short time.

In the open concurrency model, if a user receives a value from the database, another user changes the value before trying to modify the value, it is considered that there is a conflict.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.