Solved

Accessing a nested field...

Posted on 2002-05-11
4
681 Views
Last Modified: 2010-04-04
Hello,
i'm using TClientDataSet to read the data from a XML file.
I have a nested field and i need to access to its "subfields"... how can i do that through code?
I tried to read the help, it says something about using the TDatasetField class but i can't figure out how.
Let's say that i have something like this:


procedure Test;
var
 CDS: TClientDataSet;
begin
 CDS := TClientDataSet.Create(Self);  
 CDS.LoadFromFile('myfile.xml');      
 CDS.Active := True;                            
 if CDS.RecordCount > 0 then              
 begin  
  CDS.First;                                          
  //here i should read the subfields
  //of a nested field (let's call it
  //'mynestedfield')... how can i do this?
 end;
 CDS.Active := False;
 CDS.Free;
end;



Any suggestion is welcome.

Bye,
   Luca T.
0
Comment
Question by:lucat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
nestorua earned 200 total points
ID: 7004396
HI, lucat,
I don't think it's reasonable to create datasetfield
in runtime. I think you can do it in design time using
Fields Editor of the First ClientDataSet (with the field of
datasefield type) and then simply set the datasetfield property of the Second ClientDataSet to this datasetfield.

But of course you can do it in runtime.
Do it as follows:
1.Create TDatasetField object.
2.Set its Fieldname property to that of the First ClientDataSet Field which is of DataSet type (in your notation 'mynestedfield').
3.Set its Dataset property to First ClientDataSet (don't forget it must be closed in this moment).
4.Set the datasetFiled property of the Second ClientDataset
to the created DattaSetField.
5.Open the First Clientdataset.
That's all.
Sincerely,
Nestorua.
0
 

Author Comment

by:lucat
ID: 7004955
Why is it unreasonable? I need it only to read from a XML file the translations of my menus and the settings when the program starts... then i don't need it anymore... why using comp memory and resources for something that i will not use anymore?

Anyway... can you show me an example?
Shouldn't be that field a persistent field to use it that way? How do i make a field become a persistent field through code to do it?

Thank you,
   Luca
0
 
LVL 4

Expert Comment

by:nestorua
ID: 7006736
HI, lucat,
Sure I can show you an example of what I said,
but first tell me what item of my proposal you can not realize?
I seemed to give you accurate plan what to do.
Sincerely,
Nestorua.
0
 
LVL 1

Expert Comment

by:pnh73
ID: 9005640
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept answer from nestorua

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question