?
Solved

Accessing a nested field...

Posted on 2002-05-11
4
Medium Priority
?
686 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 800 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month12 days, 23 hours left to enroll

777 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