Filling a DataSet Using an XML Template Query

[ Team LiB ] Recipe Filling a DataSet Using an XML Template Query Problem You have an XML template query that you need to use from . You need to fill a DataSet using an XML template query. Solution Use an XML template query to fill a DataSet using the SQLXML Managed Classes. | Team LiB Recipe Filling a DataSet Using an XML Template Query Problem You have an XML template query that you need to use from . You need to fill a DataSet using an XML template query. Solution Use an XML template query to fill a DataSet using the SQLXML Managed Classes. The sample uses one XML file as shown in Example 8-14 Contains the XML template query The sample code contains two event handlers and one method Loads all Customers from Northwind into a DataTable. The default view of the DataTable is bound to the top data grid on the form. The event handler is called to refresh the bottom data grid. Gets the CustomerlD for the selected row in the top data grid and calls the LoadOrderGrid method to refresh the bottom grid. LoadOrderGrid This method creates a SqlXmlCommand template query and its single SqlXmlParameter object. The parameter is set to the user-specified value. A SqlXmlDataAdapter object is created and executed to fill a new DataSet based on the template query. The default view of the Orders table in the result DataSet is bound to the lower data grid on the form displaying the orders for the selected customer. Example 8-14. File xml version encoding utf-8 ROOT xmlns sql urn schemas-microsoft-com xml-sql sql header sql param name CustomerID sql header sql query select Order Details .ProductID Order Details .UnitPrice Order Details .Quantity Order Details .Discount from Orders inner join Order Details on Order Details .OrderID where @CustomerID for xml auto sql query ROOT The C code is shown in Example 8-15. Example 8-15. File .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
288    9    1    06-06-2024
8    99    2    06-06-2024
Đã 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.