Solved

Accessing a nested field...

Posted on 2002-05-11
4
666 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
loading dll from external path 1 213
Delphi TcxGrid group footer summary 3 213
select query - oracle 16 95
how to send memory stream from ics Client To ics server ? 11 83
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now