tailieunhanh - Microsoft ADO .NET 4 Step by Step - p 12
Xác định cập nhật và Xóa một quy tắc trong DataRelation: Visual Basic Lưu ý tập thể dục này sử dụng "Chương 5 VB" dự án mẫu và tiếp tục thực hiện trước trong chương này | 86 Microsoft 4 Step by Step 6. Test setting linked child fields to NULL when a parent record is deleted. Set the Delete Rule field to SetNull. Select the first row in the Flights field the one with ID 759. Click the Flights Delete button and confirm the delete action. 7. Review the Flights and Legs fields. Although the first row in the Flights field has been removed its child records in the Legs field remain. However their FlightID column values have been cleared and are set to NULL. Those records no longer have a parent row. Defining the Update and Delete Rules in a DataRelation Visual Basic Note This exercise uses the Chapter 5 VB sample project and continues the previous exercise in this chapter. 1. Open the source code view for the Flightinfo form. Locate the RefreshConstraints method. The application lets the user alter the rules for adjusting the child table when changes are made to the parent table. The RefreshConstraints routine updates the relevant constraint with the user s rule choice. 2. Just after the Alter its cascade rules comment add the following statements CType CType 3. Run the program. The Update Rule and Delete Rule fields are both set to None by default. This prevents parent records Flights from being deleted or having their ID column values changed if related child rows Legs exist. 4. Test cascade updates. Set the Update Rule field to Cascade. Select the first row in the Flights field the one with ID 834. Click the Flights Edit button. Use the Edit Flight form that appears to alter the Flight ID value from 834 to another value such as 759. Click OK on that editor form. 5. Review the Flights and Legs fields. Not only did the first row in the Flights field have its ID value changed to 759 but the FlightID values for the related rows in the Legs field changed to 759 as well. 6. Test setting linked child fields to NULL .
đang nạp các trang xem trước