RAD Studio for Microsoft .NET
ContentsIndex
PreviousUpNext
Building a Distributed Database Application

Data remoting is fundamental to developing distributed database applications. The .NET remoting technology provides a flexible and extensible framework for interprocess communication. With .NET remoting you can interact with objects in different application domains, in different processes running on the same machine, or in different machines on a network. 

Using the RemoteServer and RemoteConnection components, you can easily migrate a client/server application that uses DataHub and DataSync components to a multi-tier DataSet remoting application. RemoteServer implements IDataService and publishes itself as a singleton server activated object (SAO). On the client side, the RemoteConnection properties form the URL for connecting to the RemoteServer. Channel specifies the protocol to use (TCP/IP or HTTP), Port specifies the port on which the RemoteServer is listening for requests, and URI refers to the unique resource identifier for the RemoteServer.  

Building a distributed application with data remoting components consists of the following steps:

  • Build a server-side Windows Forms application with one or more connections to a BDP.NET data provider, a DataSync component to collect the connections and set the commit behavior, and a RemoteServer component to set the communication protocol and URI for communicating with clients
  • Build a client-side Windows Forms application with RemoteConnection component with properties to specify the connection to the server-side application, a DataHub component for passing data to and from a DataSet, and a DataGrid to display the data
Note: The RemoteServer component is hosted in Windows Forms applications without adding any additional code manually.

To create the server-side application

  1. Choose FileNewWindows Forms Application for either Delphi for .NET or C#. The Windows Forms designer appears.
  2. Choose ViewData Explorer to access the Data Explorer, and expand the Data Explorer Tree to expose the providers and database tables you want to use. You must have a live connection to expand provider nodes. If you do not have a live connection, you may need to modify the connection string.
  3. Drag and drop tables from one or more providers onto your form. For each table you drag onto your form, a BdpConnection and a BdpDataAdapter appear in the component tray. If you add multiple tables from the same provider, you can delete all but one BdpConnection for that provider.
  4. Configure each BdpDataAdapter component. There is no need to set the Active or DataSet properties, as the DataSet will be populated by the DataHub component on the client-side.
  5. Drag a DataSync component onto your form from the Borland Data Provider category of the Tool Palette, and configure the following DataSync properties in the Object Inspector:

Property 
Description 
Providers  
Specifies a collection of DataProviders to use as data sources. Click the ellipsis button to open the DataProvider Collection Editor, and add a DataProvider for each table you want to provide and resolve.  
CommitBehavior  
Specifies the logic (Atomic, Individual, or ForceIndividual) for handling failures during resolving.  

  1. Drag a RemoteServer component onto your form from the Borland Data Provider category of the Tool Palette, and configure the following RemoteServer properties in the Object Inspector:

Property 
Description 
DataSync  
Specifies the DataSync that needs remoting. Select the DataSync from the drop-down list in the Object Inspector.  
AutoStart  
Specifies whether or not to start the remote server automatically when the application runs. Set this property to True.  
ChannelType  
Specifies the channel type: Http (HTTP) or Tcp (TCP/IP). Select the channel type from the drop-down list in the Object Inspector.  
Port  
Specifies the port the remote server will be listening on. Enter a new value, or accept the default port value, 8000.  
URI  
Specifies the universal resource identifier for the remote server. By default, the URI property is the same as the Name property.  

  1. Choose RunRun to start the server-side application.

To create the client-side application

  1. Choose FileNewWindows Forms Application for either Delphi for .NET or C#. The Windows Forms designer appears.
  2. Drag a DataSet component onto your form from the Data Components category of the Tool Palette.
  3. Drag a DataGrid component to your form from the Data Controls category of the Tool Palette, and set the DataSource property for the DataGrid to the name of the added DataSet component (for example, dataSet1).
  4. Drag a RemoteConnection component onto your form from the Borland Data Provider category of the Tool Palette, and configure the following RemoteConnection properties in the Object Inspector:

Property 
Description 
ProviderType  
Specifies the type of provider published by the remote server. In this case, the property should be set to Borland.Data.Provider.DataSync. If the remote server is running, you can select this value from the drop-down list. Otherwise, you must enter the value.  
ChannelType  
Specifies the channel type: Http (HTTP) or Tcp (TCP/IP). Select the channel type from the drop-down list in the Object Inspector. This should match the setting for the remote server.  
Host  
The name or IP address of the remote server.  
Port  
Specifies the port the remote server will be listening on. Enter a new value, or accept the default port value, 8000. This should match the setting for the remote server.  
URI  
Specifies the universal resource identifier for the remote server. This should match the URI property for the RemoteServer component in the remote server application.  

  1. Drag a DataHub component onto your form from the Borland Data Provider category of the Tool Palette, and configure the following DataHub properties in the Object Inspector:

Property 
Description 
DataPort  
Specifies the data source. Set the DataPort property to the added RemoteConnection component (for example, RemoteConnection1).  
DataSet  
Specifies the DataSet to hold the data retrieved from the specified data source. Set this property to the added DataSet (for example, dataSet1).  

  1. Choose RunRun. The application compiles and displays a Windows Form with DataGrid.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!