Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Tài liệu đang bị lỗi
File tài liệu này hiện đang bị hỏng, chúng tôi đang cố gắng khắc phục.
Tài liệu Updating Server Data Using a Web Service ppt
Nội dung xem thử
Mô tả chi tiết
[ Team LiB ]
Recipe 4.11 Updating Server Data Using a Web Service
Problem
You want to update a data source using an XML web service and use the web service
from your client application.
Solution
Use a DataSet object.
The XML web service code contains two methods:
LoadOrders( )
Creates and returns a DataSet containing the Orders and Order Details tables from
Northwind and a DataRelation between those tables.
UpdateOrders( )
Takes a DataSet argument containing the changes made to the DataSet created by
the LoadOrders( ) method, creates two DataAdapter objects with
CommandBuilder generated update logic for each, and uses the DataAdapter
objects to update the Orders and Order Details tables in Northwind.
The client-side code contains two event handlers:
Form.Load
Sets up the example by calling the LoadOrders( ) method in the web service to
populate a DataSet. The default view of the Orders table is bound to the data grid
on the form.
Update Button.Click
Calls the UpdateOrders( ) method in the web service passing a DataSet containing
changes made to the DataSet since the form was loaded or since the last time the
UpdateOrders( ) method was called.
The C# code for the XML web service is shown in Example 4-25.