Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 2 - Using the Client Dataset in Two-Tiered Cli...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Using the Client Dataset in Two-Tiered Client/Server Applications
By: Danish Ahmed
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2007-12-26

    Table of Contents:
  • Using the Client Dataset in Two-Tiered Client/Server Applications
  • Two-Tiered Architecture
  • Using Data-Aware Components with the Client Dataset
  • Navigating and Modifying Data Programatically

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using the Client Dataset in Two-Tiered Client/Server Applications - Two-Tiered Architecture


    (Page 2 of 4 )

    A two-tiered client-server program is divided into two parts, a server and a client which interact with each other over a network. A data storage mechanism is implemented in the server, which allows the client to connect to itself and transact data. A server normally doesn't interact with the end user; it receives requests from the client application, processes them and sends a reply to the client application.

    A client, on the other hand, interacts directly with the end user, usually through a graphical interface. It acts as an intermediary between the user and the server.

    The two-tiered architecture is based on pretty simple logic, and for that reason it is best suited to performing simple tasks in environments with a small number of users. But even then, if the number of transactions is slightly larger, the network may be overloaded, thus degrading the performance. As I have said earlier, the client dataset component can be used to cache data locally and commit all changes to the server in a single transaction. Using the client dataset in a two-tiered application can help drastically reduce network traffic and enhance  performance. So let us take a look at how the client dataset can be used in a two-tier database application.

    A distinctive feature of the client dataset is that by itself, it cannot connect to a database source and requires a TDataset Provider class to interact with the data source. The TClient Dataset component points to the dataset provider through its Provider Name property. You can link the client dataset to its dataset provider during design time by selecting the name of the instance of the TDataset Provider in the Object Inspector and during runtime, it can be specified in a single statement.

     

    CDS11.ProviderName:=DataSetProvider1;



    The dataset provider in its turn needs to point to another dataset which is linked to the database. This can be done by specifying the dataset's name in the "dataset" property of the dataset provider. When the client dataset is opened it sends a request to the dataset provider which opens the dataset pointing to the external data source, fetches data, converts it to data packets and closes the dataset. It then passes these data packets to the client dataset, which decodes them and loads them into memory, keeping the original structure intact. Another method which you can use to specify the provider to the client dataset is the SetProvider method.

     

    CDS11.SetProvider(DataSetProvider1);


    This method can be called to link the client dataset to the dataset provider when the latter resides in the same application but has a different owner. In all other instances the Provider Name property should be used to associate the client dataset with the dataset provider.

    In fact, the SetProvider method cannot be used when the provider resides in a remote module; further, the provider you intend to associate with the client dataset has to be a descendant of the TCustomProvider class or else an exception is raised. If you really have to use this method, do remember that this method associates the provider with the client dataset as long as it is open and the linkage is lost when the dataset is closed. So every time you open the client dataset you have to assign the provider using the same method. In contrast to using this method, assigning a provider to a client dataset using its ProviderName property is a much simpler and effective way.

    The client dataset allows you to retrieve specific records from its internal and external providers by using its CommandText property. This property can be assigned an SQL statement, table name or stored procedure. When the dataset is opened or the Execute method is called and the CommandText property is not blank, the value held by it is sent to the server through the provider and the result set is sent back to the client dataset.

    Do remember that the dataset provider's Option property should have poAllowCommandText set to true to send the CommandText value to the server. It should also be noted that any data held by the client dataset after it has been associated to a data source is replaced with the data retrieved by the execution of the CommandText.

    More Delphi-Kylix Articles
    More By Danish Ahmed


     

    DELPHI-KYLIX ARTICLES

    - 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...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek