I am trying to use a clientdataset without an associated Table. I am attempting to extract and edit data from a Cad program. The Cad program has an interface in which the user selects specific entities within the Cad file (lines, circles, text etc) and provides basic information and attributes such as color, layer, linetype, text strings, etc. The intent is to have this information displayed in a TDBGrid, edited by the user and then sent back to the Cad program to change the Cad Database. Each field column in the DBGrid represents a specific data type and each record/row is the data from a separate Cad entities.

I need the Clientdataset to coordinate the information the DBGrid, but do not need any permanent reocrd of it. ONce the user finishes editing, I will use the change log to revise the Cad Data. I am not certain how to work the specific code to set the ClientdataSet up in this case (w/o a tTable) I suspect the easiset way to do this is to Connect the ClientDataSet direct to a file, but I cannot find any examples of how this is actually done.

Can anyone steer me to some examples of working with a ClientDataset using loadfromfile and savetofile. I am not sure how to set up the links between the dataset, the file and the datasource without a Ttable or other dataset. Can I create the file programmatically so that it is the correct structure? How do I create the file for the first time so that the ClentDataSet can laod or save?

8 Years
Discussion Span
Last Post by mcrosman

This worked great with the DBGrid. When I tried using a DBEdit, i have trouble getting it to connect to a specific field (eg Name). I assume I connect the edit component to a field using the "DataSetField" property under the DataSource/Dataset portion of the DbEdit properties in the Object Inspector. I am using a datamodule so my Data source includes the datamodule reference. This is connected correctly because it then identifies my ClientDataSet. Identifying the DataSetFiled as "Name" however leads to an error "Invalid Property Value"

My initial problem with the file was that I missed the option to Create DataSet. Can this be created programatically or must the file be provided to the user along with my program?


You should be able to do it (as that was the point of the db challenge I set for the guys there)

You can create it and delete it when your done :) Without checking (its late) Im fairly sure you can do it totally in memory - although there are memory table components


1. Set the Active property of the ClientDataSet to False.

2. Open the Fields Editor of the ClientDataSet.
Press Ctrl+N to open the 'New Field' dialog box to create all the fields of the ClientDataSet.
You must define:
.Field Type
for each field.

3. Set the FileName property of the ClientDataset with the
Drive:\Path\FileName of the file that must store all the data (the file name must have the .cds extension.

4. Click the right button of the mouse over the ClinetDataSet and execute the 'Create Dataset...' command.

5. Click the right button of the mouse over the ClientDataSet ant execute the 'Save to binary MyBase file...' command.
A binary file with the .cds extension will be created on the
Drive:\Path\FileName defined on the FileName property of the ClientDataSet.

After you have created the fields of the ClientDataSet and saved everything on the .cds file you can use the LoadFromFile and SaveToFile methods of the CleitnDataSet to load the data from and save the data to the .cds file created on the 5th step above.

Best regards,


This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.