TAILIEUCHUNG - Navigating Between Parent and Child Records Using a DataRelation

[ Team LiB ] Recipe Navigating Between Parent and Child Records Using a DataRelation Problem You want to navigate between the parent and child records in a hierarchical DataSet. Solution Use a DataRelation to find the child rows | Team LiB Recipe Navigating Between Parent and Child Records Using a DataRelation Problem You want to navigate between the parent and child records in a hierarchical DataSet. Solution Use a DataRelation to find the child rows for a parent row in a related table or to find the parent row for a child row in a related table. The sample code starts by creating a DataSet containing the Orders and Order Details tables from the Northwind sample database and a relation between them. The code then iterates over the Orders and uses the relation to return all Order Detail rows for each order. Finally the sample code retrieves the CustomerlD field from the parent row and displays it for each child. The C code is shown in Example 3-4. Example 3-4. File Namespaces variables and constants using System using using using using Table name constants private const String ORDERS_TABLE Orders private const String ORDERDETAILS_TABLE OrderDetails Relation name constants private const String ORDERS_ORDERDETAILS_RELATION Orders_OrderDetails_Relation Field name constants private const String ORDERID_FIELD OrderlD private const String PRODUCTID_FIELD ProductID private const String QUANTITY_FIELD Quantity private const String CUSTOMERID_FIELD CustomerID . . . DataSet ds new DataSet SqlDataAdapter da Fill the Order table and add it to the DataSet. da new SqlDataAdapter SELECT FROM Orders Sql_ConnectString DataTable orderTable new DataTable ORDERS_TABLE orderTable . Add orderT able Fill the OrderDetails table and add it to the DataSet. da new SqlDataAdapter SELECT FROM Order Details Sql_ConnectString DataTable orderDetailTable new DataTable ORDERDETAILS_TABLE orderDetailTable orderDetailTable Create a relation between the tables. ORDERS_ORDERDETAILS_RELATION .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.