Add Using the Client Dataset in File-Based Architecture


A client dataset can be used as a fully functional file-based dataset in a single-tier application as well as the client part of a multi-tiered application. A file-based application is the simplest form of database application, and it does not require a database server to save data in. Instead, it uses MyBase, the ability of client datasets to save themselves to a file and to load the data from a file.

For the purpose of demonstration let us create a very simple application that stores just four fields: first name, last name, phone number and email address. To create and use client datasets in an application that does not require a connection to the database server you can adopt one of the following three approaches.

The easiest approach to working with the client dataset without requiring a persistent server connection is by is copying data to the client dataset from another dataset. During design time this can be done by clicking on the “Assign Local Data” option available in the context menu of the client dataset component. When this option is selected, a list of available datasets is displayed and you can choose the one that contains the data you want to copy.

Well, this is the only time we will be using an external database. Once the data is copied to the client dataset you can delete the external dataset. The data as well as the structure is now contained in the client dataset component.


You can assign data to the client dataset from another data source during runtime by using the data property of the client dataset. To copy data from another client dataset component assign it using both datasets' data property.


CDS1.Data:=CDS2.Data;

However, to copy data from a dataset other than the client dataset, a dataset provider would be required. The dataset provider acts as an intermediary between the two datasets. It points to the dataset which is to be copied through its dataset property and the client dataset links to the dataset provider through its dataset property.

DatasetProvider1.DataSet:=Table1;

CDS1.Data:=DatasetProvider1.Data;

After copying data from the dataset you can delete it and the provider from the application; the client dataset is now self-contained and no longer needs them. When taking this approach you should remember that copying data is different from using the CloneCursor method. When copying data by calling “Assign Data” or using the data property the actual data is copied to the client dataset but when the CloneCursor method is called, the data is shared by the client dataset with the other dataset. Any modification of the data by one dataset is reflected in the other dataset.
Related Discussions
  • HOW CAN I DEBUG DLL (2001-01-03 00:48:24)
    Do you mean how to find internal errors while writing a DLL file or how to get the exact error while calling a DLL Function ? /Filip
  • DOT ON SCREEN (2001-01-03 03:42:55)
    Delphi does not support a Pixel function with a HDC, you have to use the Windows-API-function COLORREF SetPixel( HDC hdc, // handle...
  • HELP WITH CHDIR !!!! TURBO PASCAL VS DELPHI (2001-01-03 06:48:49)
    This is because the ChDir Procedure, the SetCurrentDir and SetCurrentDirectory Functions are changing the directory in the active process. Try...
  • DEFAULT EMAIL CLIENT (2001-01-03 23:54:27)
    HKEY_CLASSES_ROOT\mailto\shell\open\command\ /Filip
  • ADD TO RESOURCE ON RUNTIME (2001-01-04 09:00:49)
    I think what you are asking is to change the .EXE file at run-time. Yes, it is possible, but nobody I found will share that information. If you...
  • HELP WITH EXCEPTIONS ..... I'M GETTING CRAZY! (2001-01-06 19:59:49)
    How to make it run as if you were running it outside of Delphi. Tools | Debugger Options --> Language Exceptions. Their is a checkbox titled...
  • TELEPHONE BASED APPLICATION (2001-01-08 10:29:39)
    I did something like this. I wrote a fully operative phone- based banking applciation in two days using VisualVoice and Dialogic cards. However,...
  • HOW TO LOAD INI INTO A DLL (2001-01-05 14:43:45)
    unfortunatelly I haven't found anything interesting in the win32api help. I tried different methods. It seems like it is loading the data while...
  • MANIPULATING WINDOWS OF OTHER PROGRAMS (2001-01-04 19:11:41)
    You need to use the EnumWindows API function to figure out the handle of each window that you want to manipulate (you may also need to use...
  • ERROR MESSAGE "KEY FIELD CONTAINING A DUPLICATE VALUE" (2001-01-05 11:54:47)
    I am certain that you have created a field and made it a key or index field with unique properties. Being unique, if a value entered is identical...
Latest News
Submit News Form Past News
Latest Forum Entries