Start Find control in rowupdating event

Find control in rowupdating event

In the first screen, we're prompted to specify the database to connect to - connect to the same Northwind database using the . When using the DB direct pattern against a DAL that uses optimistic concurrency, the methods must be passed the new and original values. Instead, when using an optimistic concurrency-enabled DAL, we need to alter the of the product columns (as these values are overwritten in Step 2), but is essential for those overloads where only a subset of the column values are passed in as input parameters. As we discussed in the We're very close to having a fully-working example.

Enabling optimistic concurrency for a Table Adapter in the Typed Data Set augments the Table Adapter's statement, for example, updates the name and price of a product only if the current database values are equal to the values that were originally retrieved when updating the record in the Grid View. Since we are passing in the original values into the BLL, do There's one final property setting that needs to be made in order for the Object Data Source to correctly pass the original values to the BLL methods.

The , that DB direct methods were those that accepts a list of scalar values as input parameters (rather than a strongly-typed Data Row or Data Table instance). The Object Data Source has a Conflict Detection property that can be assigned to one of two values: .

For web applications that only allow users to view data, or for those that include only a single user who can modify data, there's no threat of two concurrent users accidentally overwriting one another's changes.

For web applications that allow multiple users to update or delete data, however, there's the potential for one user's modifications to clash with another concurrent user's.

Figure 1 graphically depicts this series of events.

Figure 1: When Two Users Simultaneously Update a Record There s Potential for One User s Changes to Overwrite the Other s (Click to view full-size image) Similarly, when two users are visiting a page, one user might be in the midst of updating a record when it is deleted by another user.

Figure 6: Enable Optimistic Concurrency Control by Checking the "Use optimistic concurrency" Check Box (Click to view full-size image) Lastly, indicate that the Table Adapter should use the data access patterns that both fill a Data Table and return a Data Table; also indicate that the DB direct methods should be created. As expected, the Grid View lists each product with an Edit and Delete button in the leftmost column.

Change the method name for the Return a Data Table pattern from Get Data to Get Products, so as to mirror the naming conventions we used in our original DAL. Figure 14: The Products are Listed in a Grid View (Click to view full-size image) If you click the Delete button for any product, a method.

Let's use the exact same SQL query used for the SELECT Product ID, Product Name, Supplier ID, Category ID, Quantity Per Unit, Unit Price, Units In Stock, Units On Order, Reorder Level, Discontinued, (SELECT Category Name FROM Categories WHERE Categories. Category ID) as Category Name, (SELECT Company Name FROM Suppliers WHERE Suppliers. Supplier ID) as Supplier Name FROM Products Table Adapter in the Original DAL (Click to view full-size image) Before moving onto the next screen, click the Advanced Options button. Therefore, it's essential that the required original values all are captured via two-way databinding and that they are provided in a convertible format.

To have this Table Adapter employ optimistic concurrency control, simply check the "Use optimistic concurrency" checkbox. To see why this is important, take a moment to visit our page in a browser.

Since we used ad-hoc SQL queries in our original DAL, use this option here as well. In our BLL, then, we must accept all of the original parameters as input parameters. Products Optimistic Concurrency Row product, string product Name, int? Additionally, we still need some interface that alerts the user when a concurrency violation has occurred. Refer back to Figure 2 for a graphical representation of this process.