Home arrow Delphi-Kylix arrow Page 2 - Using the Client Dataset in an N-Tiered Application

Using the Client Dataset in an N-Tiered Application

My last two articles demonstrated the use of the client dataset in a two-tier application. The two-tier architecture may be effective in some situations but in many circumstances it suffers from some serious drawbacks. This is where the concept of an n-tiered or multi-tiered architecture comes in.

Author Info:
By: Danish Ahmed
Rating: 5 stars5 stars5 stars5 stars5 stars / 8
January 02, 2008
  1. · Using the Client Dataset in an N-Tiered Application
  2. · Application Server
  3. · Client Application
  4. · Connecting to the Application Server

print this article

Using the Client Dataset in an N-Tiered Application - Application Server
(Page 2 of 4 )


The application server resides in the middle tier and acts as an intermediary between the client application and the database server. In some ways the application server plays the same role that the dataset provider plays while acting as an intermediary between the client dataset and the database server.

Creating an application server in Delphi is a bit different from creating other applications. If you intend to create a web service using SOAP as the transport protocol, choose Web Server as the the type of application in the SOAP Server application category of the new item dialog box. If you are using any other protocol like DCOM or TCP/IP, simply select new application from the File menu or New Items dialog box.

What makes the application server different from other applications is the remote data module which acts as the broker for the application server. You can add the TRemoteDataModulecomponent to your application from the Multitier category of the New Items dialog box. This module acts as the repository of all objects in an application server and implements the IAppServer interface that the client application uses to connect to the server. When you create a new RemoteDataModule, you are required to specify a class name which acts as the base name of the interface of that class. You can also specify the kind of threading model you want to implement and the number of instances you wish to allow.

If you are creating a Web Service you can add TSoapDataModulefrom the Web Services page of the New Items dialog box. It implements an invokable interface, the IAppServerSOAPinterface, to communicate information in a SOAP-based multi-tiered database application. As with TRemoteDataModule, TSoapDataModule alsorequires a class name during creation which acts as the base name of the interface for that class. There are more ways to create an application server but I will not go into the details. Instead, I will proceed to demonstrate how a remote data module and dataset provider can be utilized in the application server.

After adding a remote data module according to your requirements, drop database components that interact with the database server on the data module. For instance, to connect to a Microsoft SQL Server using ADO, drop a TADOTable component, specify the connection parameters in its ConnectionStringproperty and the table you want to access in the TableName property. Next add a dataset provider component and assign the TADOTable component's name to the dataset property of the dataset provider. This will ensure that when the client dataset connects to it and requests data, it will fetch the required records from the connected TADOTable instance. Add a dataset provider component for every dataset that you want to access from the client. If you are using XML documents for storing data, add a XMLProvider component for every XML document.

You can use the event handlers of the module to write code to ensure that the transactions and operations conform to the business rules. They can also be used to implement custom methods and influence the data packets that are being sent to the server for update. This feature is discussed in the follow-up article.

An application server does not initiate connection with the client; it waits for the client to initiate a connection. So after creating the application it would be necessary to make sure that it is found by the client application. Executing it once to get it registered as an application server, the client application can then find it and receive the IAppServer interface through which it interacts with the application server. You can also register it by passing the “/regserver” parameterin the command line or using the parameter option in the IDE. To unregister it, simply pass the “/unregserver” parameter. 


blog comments powered by Disqus

- Loading an XML Document into the DOM
- Delphi Wrapper Classes and XML
- Delphi and the DOM
- Delphi and XML
- Internet Access: Client Service
- Finishing the Client for an Internet Access ...
- The Client for an Internet Access Control Ap...
- User Management for an Internet Access Contr...
- Important Procedures for an Internet Access ...
- Server Code for an Internet Access Control A...
- Constructing the Interface for an Internet A...
- Building a Server Application for an Interne...
- Building an Internet Access Control Applicat...
- Client Dataset: Working with Data Packets an...
- Using the Client Dataset in an N-Tiered Appl...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials