4.12. Updating Server Data Using .NET Remoting
Problem
You want to update a data source using .NET remoting and use the remote application from your client application.
Solution
Use
System.MarshalByRefObject to create
a
remoteable class.
The server-side code that registers the remoteable class for remote activation contains one event handler and one configuration file:
- Start Server
Button.Click Registers the remoteable class
RemoteClassfor remote activation.- Server-side configuration file
Contains parameters used to register the class and the channel on the server so that the class can be activated from another application domain.
The remoteable class code contains two methods:
LoadOrders( )Creates and returns a
DataSetcontaining the Orders and Order Details tables from Northwind and aDataRelationbetween those tables.UpdateOrders( )Takes a
DataSetargument containing the changes made to theDataSetcreated by theLoadOrders( )method, creates twoDataAdapterobjects withCommandBuilder-generated update logic for each, and uses theDataAdapterobjects to update the Orders and Order Details tables in Northwind.
The client-side code contains two event handlers and one configuration file:
Form.LoadSets up the example by calling the
LoadOrders( )method in the remote object to populate aDataSet. 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 remote object passing aDataSetcontaining changes made to the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access