Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 3 - Using the Client Dataset in File-Based Arc...
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  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
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 File-Based Architecture
By: Danish Ahmed
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2007-12-19

    Table of Contents:
  • Using the Client Dataset in File-Based Architecture
  • Adding FieldDefs
  • Adding IndexDefs
  • Loading and Saving Files

  • 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 File-Based Architecture - Adding IndexDefs


    (Page 3 of 4 )

    Indexes are useful for not only sorting and grouping data but searching for records and setting up relationship with other datasets as well. When working with the client dataset, indexes can be created at both design time and runtime, but before the dataset has been created. The process is fairly similar to creating field definitions except for the fact that, unlike field definitions, index definitions are optional.

    When the client dataset represents server data it inherits the default index of the records, which can be used to order the records in the dataset. But it does not allow you to modify it; instead, the index of the modified data is maintained in the ChangeLog or Delta as CHANGEINDEX. This changed index too is maintained by the client dataset and does not allow you to change or modify it.

    To work with an editable index you can create one using the IndexFieldName property. Specify the name of the fields on which you want to add an index to the IndexFieldNames property of the client dataset. Multiple field names can be specified by separating them with semicolons and specifying them in the order that you would want the index to be created with. This method can be used to create a temporary index during runtime and is useful only if you want to create an index for sorting only. It does not support grouping and cannot sort records in descending order.

    To create an index during runtime that supports grouping you can use the AddIndex method. This method gives you a lot more flexibility, allowing you to specify the name of the index, the fields that make it up, the default level of grouping support and how the indexes are sorted. You can sort them case-insensitively or in descending order, neither of which is allowed when you create an index using the IndexFieldName property. Indexes created using this method are not persistent and are lost as soon as the dataset is closed.

    To work with indexes that persist and are saved, you can use the IndexDefs property. You can create persistent indexes at design time by using the Object Inspector. Select the client dataset component and in the Object Inspector click on the ellipses button of the IndexDefs property. This brings up the Collection editor which allows you to add, modify or remove properties of field definitions visually. To add index definitions at runtime call the AddIndexDef method. This method adds a new IndexDef and requires you to specify the name, type, and options of the index that will be created.

     

    CDS1.IndexDefs.Clear;

    with CDS1.IndexDefs.AddIndexDef do

    begin

    Name := 'fnIndex';

    Fields := 'fName';

    Options := [ixPrimary];

    end;

    end;

    As is evident from the code above, for every index definition added you also need to specify the attributes of the index by specifying it in the property of the IndexDefs object. It should be noted that the AddIndexDefs method needs to be called before the dataset is created.

    After the field definitions and index definitions have been created, call the CreateDataset method to create an in memory dataset for the application.

    More Delphi-Kylix Articles
    More By Danish Ahmed


     

    DELPHI-KYLIX ARTICLES

    - 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...
    - Using the Client Dataset in Two-Tiered Clien...
    - Using the Client Dataset in File-Based Archi...
    - Demystifying the Client Dataset
    - Working with INI Files in Delphi
    - Creating Data Link (UDL) Files in Delphi
    - Looking at the Details for an Invoicing Appl...
    - Invoicing in Delphi: Show Me the Money
    - Saving Images and Binary Files to a Database...
    - Saving Files to a Database using Delphi: Sav...
    - Creating CF Applications and Integrating a S...







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway